LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-10-2012, 09:52 AM   #1
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Rep: Reputation: 48
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
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 04-10-2012, 12:28 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
Quote:
Originally Posted by rjo98 View Post
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?..
 
2 members found this post helpful.
Old 04-10-2012, 12:51 PM   #3
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48
thanks unSpawn, maybe someone will know for just the regular ftp as well.
 
Old 04-11-2012, 10:06 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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
 
1 members found this post helpful.
Old 04-13-2012, 03:07 PM   #5
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48
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.
 
Old 04-15-2012, 09:07 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep'ing and sed'ing chunks in bash... need help on speeding up a log parser. elinenbe Programming 4 04-22-2009 11:17 AM
Problem while FTP ing the files kmalla AIX 6 02-13-2007 01:36 PM
Need help FTP'ing into my web site imsam Linux - Newbie 3 04-09-2006 07:32 PM
No route to host (only when ftp'ing) rev1 Linux - Networking 3 03-23-2004 09:12 PM
ftp-ing a directory princenux Linux - Networking 2 06-12-2003 09:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration