Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    1

    Question Unanswered: 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 10:22.

  2. #2
    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.
    Last edited by fla5do; 12-02-03 at 18:29.
    Greetings from germany
    Peter F.

  3. #3
    Join Date
    Dec 2003
    Posts
    5

    Re: FTP and Shell Scritpting

    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.

  4. #4
    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
    `

    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???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •