If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > FTP and Shell Scritpting

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-02-03, 09:08
JayZee JayZee is offline
Registered User
 
Join Date: Dec 2003
Posts: 1
Question FTP and Shell Scritpting

Help! I'm a UNIX newbie!

I'm trying to FTP to a server and get the most recent file and then pass the name to a variable which I need to modify (in the variable).

Is this possible???

Last edited by JayZee; 12-02-03 at 09:22.
Reply With Quote
  #2 (permalink)  
Old 12-02-03, 17:16
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
try this

# Edit your .netrc in your local homedirctory or create it with following
# parameters
# machine sapdata login xyz password xyz
# use chmod 600 .netrc for the right permissions
# FTP start
REMOTE_SERV="sapdata"
LOG_FILE="ftp_log.txt"
REMOTE_PATH="."
LOCAL_PATH="."
ftp $REMOTE_SERV <<-! 2>&1 | tee -i -a $LOG_FILE > /dev/null 2>&1
cd $REMOTE_PATH
lcd $LOCAL_PATH
dir
bye
!
# now you can edit the log file or
# load the log file by awk for further work in this script

# I donīt know how to get the recent files of the remote machine
# but you can work with the logfile and select your files by date and
# time for your own, by using awk.
__________________
Greetings from germany
Peter F.

Last edited by fla5do; 12-02-03 at 17:29.
Reply With Quote
  #3 (permalink)  
Old 12-03-03, 23:30
Dahn Dahn is offline
Registered User
 
Join Date: Dec 2003
Posts: 5
Re: FTP and Shell Scritpting

Quote:
Originally posted by JayZee
Help! I'm a UNIX newbie!

I'm trying to FTP to a server and get the most recent file and then pass the name to a variable which I need to modify (in the variable).

Is this possible???
What system are you on. I worked on aix and it had a .ftp or some default script that was read and executed by default when you ran ftp.
Reply With Quote
  #4 (permalink)  
Old 12-10-03, 09:45
dmmac dmmac is offline
Registered User
 
Join Date: Aug 2003
Location: Massachusetts, USA
Posts: 106
Re: FTP and Shell Scritpting

Another possibility

TODAY=`date +%m-%d-%Y`

FILES=`ftp -n server << EOFTP | grep -v $TODAY
user $USER $PSWD
cd somedirectory
prompt
ls -t <-- most recent file will be at the top
bye
EOFTP
`

Quote:
Originally posted by JayZee
Help! I'm a UNIX newbie!

I'm trying to FTP to a server and get the most recent file and then pass the name to a variable which I need to modify (in the variable).

Is this possible???
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On