- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: scripting issue
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
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
Community
Resources
Forums
Blogs
- 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-30-2001 12:24 PM
08-30-2001 12:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2001 12:28 PM
08-30-2001 12:28 PM
Re: scripting issue
You could look at using tcl/tk to script the session, but it's a lot to learn if you have never used it before.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2001 12:38 PM
08-30-2001 12:38 PM
Re: scripting issue
I trap the return messages like this
ret=`ftp -n -v 2>&1 <<- END
open ${SERVER}
user ${USER} ${PASSWORD}
${TYPE}
lcd ${TO_DIR}
cd ${FROM_DIR}
get ${ORIGINAL_FILENAME} {NEW_FILENAME}
bye
END`
echo "$ret" | grep -q -i "incomplete"
if [[ $? -eq 0 ]]
then
echo "Ftp failed to get files"
exit 1
fi
echo "$ret" | grep -q -i "failed"
if [[ $? -eq 0 ]]
then
echo "Ftp failed to get files"
exit 1
fi
echo "$ret" | grep -q -i "No such"
if [[ $? -eq 0 ]]
then
echo "Ftp failed to get files"
exit 1
fi
echo "$ret" | grep -q -i "denied"
if [[ $? -eq 0 ]]
then
echo "Ftp failed to get files"
exit 1
fi
echo "$ret" | grep -q -i "refused"
if [[ $? -eq 0 ]]
then
echo "Ftp failed to get files"
exit 1
fi
echo "$ret" | grep -q -i "aborted"
if [[ $? -eq 0 ]]
then
echo "Ftp failed to get files"
exit 1
echo "$ret" | grep -q -i "cannot"
if [[ $? -eq 0 ]]
then
echo "Ftp failed to get files"
exit 1
fi
echo "$ret" | grep -q -i "Not connected"
if [[ $? -eq 0 ]]
then
echo "Ftp failed to get files"
exit 1
fi
Ashish Tripathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2001 12:39 PM
08-30-2001 12:39 PM
Re: scripting issue
yadda yadda yadda
put file
get file file.check
!
diff file file.check
if [ $? -ne 0 ]
then
error routine
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2001 12:39 PM
08-30-2001 12:39 PM
Solutionftp -v server << EOF > /tmp/logfile 2>&1
cd directory
put file
bye
EOF
grep "Not Connected" /tmp/logfile|grep -v grep
if [ $? = 0 ]
then
echo "Error on ftp"
fi
It should work.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2001 12:40 PM
08-30-2001 12:40 PM
Re: scripting issue
get directory/file /tmp/diditwork
and then at the end of your script cksum the original and comapre that to the cksum of the temp file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2001 12:42 PM
08-30-2001 12:42 PM
Re: scripting issue
The 'ftp' session doesn't return an exit value denoting success or failure.
If you really want to decipher success/failure you can parse the three-digit numbers included with the reply from each 'ftp' command. Redirect the ftp session's verbose output into a logfile and parse the replies. The man pages (1M) for 'ftpd' [the daemon] discusss the reply format. Essentially, the first digit of the message indicates whether the reply is good, bad, or incomplete.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2001 12:47 PM
08-30-2001 12:47 PM
Re: scripting issue
One more comment. When analyzing ftp's replies, the format consists of a three-digit number, a space, some text, and an end-of-line.
The numbers are standard. The text will vary operating system to operating system. Hence is is safer to parse and analyze the 3-digit number in the reply.
Regards!
...JRF...