Operating System - HP-UX
1752518 Members
5099 Online
108788 Solutions
New Discussion юеВ

Re: Need help moving from ftp to scp

 
Thomas Jones2
Occasional Advisor

Need help moving from ftp to scp

The HP account here is under mandate to move to secure ftp. We have scripts that use ftp transfer and the passwords are maintained in netrc files.

After the keys are established, would I be able to simply replace the ftp in the commands with scp?

Also will the error checking greps still work?

I have attached an example script which was generated & run by a batch program.
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor

Re: Need help moving from ftp to scp

Hi Thomas:

Your 'scp' will return zero for success and non-zero for failure. You can test this.

You could also redirect any STDERR to a file which you could parse for more specific failure analysis:

# scp -p srcfile desthost:destfile 2>/var/tmp/scp.$$

Regards!

...JRF...
Thomas Jones2
Occasional Advisor

Re: Need help moving from ftp to scp

Here is a script example(all but 2 gets removed):

ftp -i -v pla_img_prod >/app/pro1/if/image_retrieval/image_retrieval_work_out/if280ftp20080918092427.0001.log 2>&1 << !
binary
get "lolcb\LC6569\ky8246020059e644.pdf" /app/pro1/if/image_retrieval/image_retrieval_work_in/ky8246020059e644.pdf
! echo GETTING FILE 1 ky8246020059e644.pdf

quit
!
if egrep -i "Connection timed out" /app/pro1/if/image_retrieval/image_retrieval_work_out/if280ftp20080918092427.0001.log 1>/dev/null 2>&1
then exit 1
elif egrep -i "Not connected" /app/pro1/if/image_retrieval/image_retrieval_work_out/if280ftp20080918092427.0001.log 1>/dev/null 2>&1
then exit 2
elif egrep -i "aborted" /app/pro1/if/image_retrieval/image_retrieval_work_out/if280ftp20080918092427.0001.log 1>/dev/null 2>&1
then exit 3
elif egrep -i "error" /app/pro1/if/image_retrieval/image_retrieval_work_out/if280ftp20080918092427.0001.log 1>/dev/null 2>&1
then exit 4
elif egrep -i "Login failed" /app/pro1/if/image_retrieval/image_retrieval_work_out/if280ftp20080918092427.0001.log 1>/dev/null 2>&1
then exit 6
fi
file_cnt=`egrep -ci "GETTING" /app/pro1/if/image_retrieval/image_retrieval_work_out/if280ftp20080918092427.0001.log`
trans_cnt=`egrep -ci "226 TRANSFER COMPLETE" /app/pro1/if/image_retrieval/image_retrieval_work_out/if280ftp20080918092427.0001.log`

if [ $file_cnt -eq $trans_cnt ]
then exit 0
elif [ $file_cnt -ne $trans_cnt ]
then exit 5
fi

And a example of the file which is greped for errors:

Connected to usplswebh04a.
220 usplswebh04a Microsoft FTP Service (Version 5.0).
331 Password required for lcftp001.
230 User lcftp001 logged in.
Remote system type is Windows_NT.
200 Type set to I.
200 PORT command successful.
150 Opening BINARY mode data connection for lolcb\LC6569\ky8246020059e644.pdf(44685 bytes).
226 Transfer complete.
GETTING FILE 1 ky8246020059e644.pdf
44685 bytes received in 1.57 seconds (27.75 Kbytes/s)
200 PORT command successful.
150 Opening BINARY mode data connection for lolcb\LC6064\ky7904800059ecf7.pdf(46878 bytes).
226 Transfer complete.
GETTING FILE 2 ky7904800059ecf7.pdf
46878 bytes received in 7.99 seconds (5.73 Kbytes/s)
200 PORT command successful.
150 Opening BINARY mode data connection for lolcb\LC7074\ky8626190059ecf6.pdf(49003 bytes).
226 Transfer complete.
Tingli
Esteemed Contributor

Re: Need help moving from ftp to scp

For that case, you will use ssh for security file transfer. And you can use sftp to replace ftp. There are some difference between ftp and sftp and you need to use man page to figure out the difference.
Steven E. Protter
Exalted Contributor

Re: Need help moving from ftp to scp

Shalom,

Try this:
http://www.hpux.ws/?p=10

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com