LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   FTP'ing via a .sh, can you log what happens? (https://www.linuxquestions.org/questions/linux-newbie-8/ftping-via-a-sh-can-you-log-what-happens-939086/)

anon091 04-10-2012 08:52 AM

FTP'ing via a .sh, can you log what happens?
 
I have a .sh that does some FTP'ing for us, a modified version of it at the bottom.

The script runs very early in the morning, and sometimes doesn't work. Is there an option or something I can add in somewhere to where it'll log what it does or any errors it gets? I'd just like it to maybe write to a file i could read in the morning at a reasonable hour, then it would just overwrite that file every day, so i dont end up with some massive log file since i'd only really need to see the info from the night before.



ftp -n -i 1.2.3.4 << EOF
user username password
bin



cd /dir1/


lcd /stuff/to/upload/
put *.txt
mput *.jpg

lcd /more/stuff/to/upload/
put *.txt
mput *.jpg

close
quit
EOF

unSpawn 04-10-2012 11:28 AM

Quote:

Originally Posted by rjo98 (Post 4649254)
Is there an option or something I can add in somewhere to where it'll log what it does or any errors it gets?

Ftp I don't know but lftp supports settings like
Code:

set cmd:trace yes
set cmd:verbose yes
set ftp:passive-mode on

and such in ~/.lftprc?..

anon091 04-10-2012 11:51 AM

thanks unSpawn, maybe someone will know for just the regular ftp as well.

chrism01 04-11-2012 09:06 PM

Well, if it generates an error msg, it should go to stdout/stderr, so just capture those
Code:

myftpcmds.sh >myftpcmds.log 2>&1

# also consider adding the following to the top of the cmd file
set -xv


anon091 04-13-2012 02:07 PM

Thanks Chris. i'll give that a shot.

i've seen that at the top of other .sh's before but never knew what it was for.

chrism01 04-15-2012 08:07 PM

Well, http://ss64.com/bash/set.html but in short those 2 options show you what the parser is seeing/doing ie before & after versions of the cmds.


All times are GMT -5. The time now is 11:18 PM.