FTP Output


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers FTP Output
# 8  
Old 02-10-2004
Here ya go .......

Code:
#!/bin/ksh

#############################################################################
#       check_log - Checks the status message of the FTP log	            #
#############################################################################
function check_log {

    /usr/bin/grep "Transfer complete" ${FTP_LOG}
    result=${?}

    if [[ ${result} -ne 0 ]] then
       /usr/bin/grep "Login incorrect" ${FTP_LOG}
       result=${?}
       if [[ ${result} -eq 0 ]] then
          errorExit "Username/Password incorrect"
       fi

       /usr/bin/grep "Unknown host" ${FTP_LOG}
       result=${?}
       if [[ ${result} -eq 0 ]] then
          errorExit "Unknown Destination Host [${DEST_SERVER}]"
       fi

       /usr/bin/grep "path name does not exist" ${FTP_LOG}
       result=${?}
       if [[ ${result} -eq 0 ]] then
          errorExit "Path name does not exist [${DEST_PATH}]"
       fi

       /usr/bin/grep "file access permissions" ${FTP_LOG}
       result=${?}
       if [[ ${result} -eq 0 ]] then
          errorExit "Invalid File Access Permissions [${DEST_PATH}]"
       fi

       errorExit "An unknown error has occured during FTP"
    fi
}

#############################################################################
#       ftp_file - Perform File FTP                                         #
#		   The following function will overwrite an existing file   #
#		   in the destination path automatically. To prevent this,  #
#		   remove the line "copylocal".			            #
#############################################################################
function ftp_file {

    tmpTrimFile=`basename ${FILE}`

ftp -ivn ${DEST_SERVER} > ${FTP_LOG} 2>&1 << EOF
user ${DEST_USER} ${DEST_PWORD}
copylocal
put ${FILE} ${DEST_PATH}${tmpTrimFile}
bye
EOF

}


Last edited by lindeng; 02-10-2004 at 10:21 PM..
# 9  
Old 02-10-2004
.....

Last edited by druuna; 05-21-2009 at 10:18 AM..
druuna
# 10  
Old 02-10-2004
Hi druuna,

Duh! I knew it would be something like that - should have picked it up myself. Thanks for finding it though.

The ]] then construct seems to work fine. i.e. the script NOW does everything I expect it to.

Thanks for all the help guys - very much appreciated.

Cheers,
Linden
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute python file, FTP output to another server

Greetings all, We are implementing a new tool called URLwatch which is a python utility. Here are the requirements. 1) Run every 10 seconds 2) Execute the python script 3) Output file gets generated, FTP it to a differernt server I gave no idea how to do this and management needs a demo... (3 Replies)
Discussion started by: jeffs42885
3 Replies

2. Shell Programming and Scripting

How to redirect the output of a command inside ftp block?

hi, i am using ftp to get files from remote server. inside the ftp i want to us ls -ltr command and send the output of it to a file. ftp -n remote_server <<_FTP quote USER username quote PASS password prompt noprompt pwd ls -ltr get s1.txt bye _FTP i... (4 Replies)
Discussion started by: Little
4 Replies

3. Shell Programming and Scripting

How to redirect output of a command to a variable during ftp mode?

Hi, How can I redirect the output of a following command to a variable. ftp myservername ftp> user (username) guptaji 331 Password required for guptaji. Password: ftp> size /home/salil/abc.dat ftp> a='size /home/salil/abc.dat' ?Invalid command I want to redirect value of size to... (1 Reply)
Discussion started by: Salil Gupta
1 Replies

4. UNIX for Advanced & Expert Users

Not logging ftp connections in /var/adm/wtmpx file (in last command output)

Hi all, I have F5 load balancer on my system and checking service status by opening an ftp session in every 30 seconds. These ftp sessions are being logged in /var/adm/wtmpx and filling up the file. when i run the last command most of the output is this ftp session. I was wondering if there is a... (1 Reply)
Discussion started by: cepxat
1 Replies

5. Shell Programming and Scripting

Ftp script to output a directory name

Is there any way to include a directory name before the filename in the ftp session? Here is the script. DIRECTORY=`cat directory.txt|sed '/^$/d'` ( exec 4>&1 ftp -n>&4 2>&4|& print -p open $host print -p user $user $password print -p binary for D1 in... (0 Replies)
Discussion started by: ranjanp
0 Replies

6. Shell Programming and Scripting

rsh to many hosts the ftp output to single host

Hi guys. i need some help, i need to create a script in tcsh that rsh into all my hosts that we have at our business, then cd to a directory (cd /apps/users) then grab a file from the users folder and ftp it back to my windows machine. can someone please help? Kind regards. Brian Behrens (2 Replies)
Discussion started by: brian112
2 Replies

7. Shell Programming and Scripting

FTP stores unwanted chars to output file

I want to only store date of all files. However, the below script also store unwanted FTP related lines to output file. Could someone tell me how to ignore them (see output first 6 lines)? Thanks #Defining variables and assigning values USR='admin' PASSWD='abc'... (3 Replies)
Discussion started by: dipeshvshah
3 Replies

8. Shell Programming and Scripting

passing parameter to ftp script from output of another ftp

Hi, I have a ftp script which first gets all the file names and echo's the latest file. I'm using another ftp command sets to get the file name given by first ftp. The problem is the parameter is not accepted by second ftp. The error message i'm getting is > Rename Temp File calloc:ICMP... (5 Replies)
Discussion started by: ammu
5 Replies

9. Linux

Output to 1 file from two files in FTP

I am currently in FTP. I want to transfer two files and need the out put in One file. Can you help me.... For eg: if i am doing mget from 1 server to other. (1 Reply)
Discussion started by: manish.s
1 Replies

10. Shell Programming and Scripting

redirect output of FTP

Hi, I call the FTP command from within a script. The call to FTP looks like this : ftp -n -i -v < $com >> "$logfile" Where $com is a commandfile and I want the output to be redirected to $logfile. If I do this call at the prompt it works perfect. (replacing the variables by there... (4 Replies)
Discussion started by: kcaluwae
4 Replies
Login or Register to Ask a Question