Capturing output from background FTP command
Hi everyone
I wrote a small script that connect to a FTP to get some files, pass them to a java apps someone else wrote and once converted, send them back to that FTP. I want to capture the output of the FTP command I execute so I can send back error message when something wrong happen. (unable to connect, dns error and such.) The script is ran from a normal user account throught cron every minutes. ( 55 times / hours actually ) I write a FTP command script on the fly, then launch it like that: script -c autogenftp.sh ftpoutput.txt The problem is that the damn script command hang once in a while. Not everytime.. vary from no hanging in a hour to as much as hanged 12 times in the hour. And I end up with a whole lot of hung process that polute my server. I tried many things sh autogenftp.sh 2&>1 ftpoutput.txt sh autogetftp.sh | tee ftpoutput.txt sh autogetftp.sh 1> ftpoutput.txt But this doesnt work I only get error message like output to local-file: ./list [anpqy?]? 'EPSV': command not understood (ie I only get FTPs error message no good message) Yeah I know... For the moment I run this once an hour to clean them up ps axf | grep "script -c /home/user" | awk '{ print $1 }' | xargs kill -9 But thats not sexy in a work environment. I want something that works.. not something I need a patch for it to work.. Anyone knows another way to capture a FTP output ? This is what I need to capture (I ran the script manually instead of in cron) Connected to someserver 220 Microsoft FTP Service 331 Password required for user. 230 User user logged in. Remote system type is Windows_NT. 250 CWD command successful. 250 CWD command successful. 250 CWD command successful. output to local-file: /home/user/conversion/temp/ftplist-463290000 [anpqy?]? 500 'EPSV': command not understood 227 Entering Passive Mode (10,99,0,182,18,31). 125 Data connection already open; Transfer starting. 226 Transfer complete. 221 Im running SLES 9 (Suse Linux Enterprise Server) I welcome any comment or suggestion. Thanx for your time everyone |
Code:
sh autogenftp.sh >./ftpoutput.log 2>&1 |
Quote:
I don`t know why everywhere I look it says something like that, but it doesn`t work with either FTP or SuSE Anyone has other suggestions ? |
Use option -v of ftp
Quote:
|
Have you tried "curl" ?
I don't know if ordinary ftp clients are good for scripts, curl is meant to be used for that. ftp-upload: Code:
curl --verbose --user username:passord --upload-file /tmp/some_file ftp://hostname:21/file_goes_here/ Code:
curl --verbose --user username:password ftp://hostname:21/somefile --output somefile |
All hail rtspitz
Looking good so far!
Thats what I was looking for rtspitz! Thank you. I'll keep you posted but so far so good. I only needed to change and use something else and curl seems to do what I needed. Thank you very much! |
Thanx you all
curl works great!
I want to thank all of you for your ideas and suggestions. |
All times are GMT -5. The time now is 04:13 AM. |