I have been offered to supply an international weather station our live wind report from WD for our region and they have asked me for the following information to be uploaded in a Text file to there server every 15 minutes, has anyone any idea how i can get this data in a text file automatically in this format every 15 minutes?
Format:
1.Name \t 2.3.4.day-month-year \t 5.hour:6.minutes \t 7.airtemp \t 8.max air temp \t 9.min air temp \t 10.windspeed \t 11.gusts \t 12.wind direction in degrees (0-360) \t 13.Pressure (in hPa)
Explanation:
\t symbolizes a tab but can be written as \t as well
decimal places are separated by dot (.) or comma (,) or can be skipped
the elements of the date can be separated by dots (.) or minus (-)
single values can be missing but have to be indicated with a tab
The source code has been modified to add the ability for it to create a file (weatherinfo.txt) and then FTP the file to the ftp server. The new code is prevented from executing by an exit.
You need to do several things to use it…
create a file called weatherinfo.txt (or whatever filename you need to send) on your webserver and make sure it has chmod 666 permissions.
Edit the script to:
a) comment out the echo to screen
b) remove the exit; after the echo
c) correct the filename name if you use something other than weatherinfo.txt
d) place the ftp server name you need to send to
I updated the source to include a commented out section that would do that.
// If you needed to change to a directory like weather
// you would uncomment this section...
if (@ftp_chdir($conn_id, "weather")) {
echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";
} else {
echo "Couldn't change directory\n";
}
Warning: ftp_fput() [function.ftp-fput]: willys_test.txt: Permission denied in /var/www/vhosts/example.com/httpdocs/wind_test.php on line 115
There was a problem while uploading willys_test.txt
i have set the chmod permissions to 666
also using your updated code it is saying - Couldn’t change directory
ok so i commented out the directory change code you added and i still receive the previous error.
Warning: ftp_fput() [function.ftp-fput]: willys_test.txt: Permission denied in /var/www/vhosts/example.com/httpdocs/wind_test.php on line 115
There was a problem while uploading willys_test.txt
actually my destination path was wrong, just ensure to supply the entire path from root of the FTP, for example all the visible files on this domain are in httpdocs so to get the chdir to “windtest” i was required to change the code to httpdocs/windtest