GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: FTP status
Operating System - HP-UX
1847925
Members
4654
Online
104021
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 10:00 AM
08-09-2007 10:00 AM
FTP status
Hi everyone,
I am getting/putting the file from remote server then i delete the file from my server.
I want to check the status before i delete or moved the file from server. I want to check if any "Login failed" and "host not connect" error through scripts. I found that if it ftp return "221" means it exits from the ftp session wheather it is successful or "Login failed" but for "host not connect" it want display any number.
I want to check through "if" condition. Can you please tell me how i can check the condition in scripts.
Pls find the following scripts which doesn't check proprly.
T1=`grep "221 " FTPLOGOUT`
T2=`grep "Login failed" $FTPLOGOUT`
if [ "$T1" -eq "221 " ]
then
if [ "$T2" -ne "Login failed." ]
then
rm *
echo "FTP Done"
else
echo "FTP Failed : Login Failed(cbpout)" >> $MAILLOG
fi else echo "FTP failed : Host not connected(cbpout)" >> $MAILLOG
fi
Thanks
Manish
I am getting/putting the file from remote server then i delete the file from my server.
I want to check the status before i delete or moved the file from server. I want to check if any "Login failed" and "host not connect" error through scripts. I found that if it ftp return "221" means it exits from the ftp session wheather it is successful or "Login failed" but for "host not connect" it want display any number.
I want to check through "if" condition. Can you please tell me how i can check the condition in scripts.
Pls find the following scripts which doesn't check proprly.
T1=`grep "221 " FTPLOGOUT`
T2=`grep "Login failed" $FTPLOGOUT`
if [ "$T1" -eq "221 " ]
then
if [ "$T2" -ne "Login failed." ]
then
rm *
echo "FTP Done"
else
echo "FTP Failed : Login Failed(cbpout)" >> $MAILLOG
fi else echo "FTP failed : Host not connected(cbpout)" >> $MAILLOG
fi
Thanks
Manish
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 10:54 AM
08-09-2007 10:54 AM
Re: FTP status
Hi Manish,
You should seriously think about rewriting your script in Perl, and use the Net::FTP module.
It will be far more stable.
http://search.cpan.org/~gbarr/libnet-1.21/Net/FTP.pm
Hope this helps,
Regards,
Rob
You should seriously think about rewriting your script in Perl, and use the Net::FTP module.
It will be far more stable.
http://search.cpan.org/~gbarr/libnet-1.21/Net/FTP.pm
Hope this helps,
Regards,
Rob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 11:56 AM
08-09-2007 11:56 AM
Re: FTP status
Trying to do this in the shell is very tedious and FTP's error codes mean different things at different times. It's MUCH easier to do it in Perl and you get error checking for free. The attached script, ftpput.pl, will ftp to host "mouse" as user "mickey", password "secret", cd to /aaa/bbb, set ASCII mode, try every file up to 3 times, and put file1, file2, and file3. It will even read the password from a .netrc file so that it doesn't have to be passed on the command line. You don't have to know any Perl at all. All you have to do is test the exit status. If it's 0, all went well otherwise a non-zero exit code is set and an error message is output on stderr.
typeset -i STAT=0
ftpput.pl -h mouse -l mickey -p secret \
-d /aaa/bbb -A -h 3 file1 file2 file3
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Ftp failed; status ${STAT}." >&2
fi
exit ${STAT}
Invoke as ftpput.pl -u for full usage.
typeset -i STAT=0
ftpput.pl -h mouse -l mickey -p secret \
-d /aaa/bbb -A -h 3 file1 file2 file3
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Ftp failed; status ${STAT}." >&2
fi
exit ${STAT}
Invoke as ftpput.pl -u for full usage.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 11:58 AM
08-09-2007 11:58 AM
Re: FTP status
... and here is ftpget.pl. Invoke as ftpget.pl -u for full usage. The really good news is that if you have Perl installed on a Windows box, the Perl scripts work equally well there as well as on UNIX.
If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP