- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help on Script needed
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
03-18-2004 08:09 PM
03-18-2004 08:09 PM
Help on Script needed
Below is a sample of the script I'm working on. I cannot remember how to do the "no error" bit. Please help.
rcp -p /sdata/files/cptester/r1.txt a646001:/home/amartir/main_unix.txt
IF no error THEN
mailx -s"Copy of Main_Unix to DSA" elit
rm /sdata/files/cptester/r1.txt;;
rcp -p /sdata/files/cptester/r2.txt a646001:/home/amartir/sub_unix.txt
IF no error THEN
mailx -s"Copy of Sub_Unix to DSA" elit
rm /sdata/files/cptester/r2.txt;;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 08:13 PM
03-18-2004 08:13 PM
Re: Help on Script needed
You can try with:
if [ $? -eq 0 ]
$? is exit error code, and if it is 0 the command properly.
Boris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 08:15 PM
03-18-2004 08:15 PM
Re: Help on Script needed
then
command
fi
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 08:17 PM
03-18-2004 08:17 PM
Re: Help on Script needed
rcp -p /sdata/files/cptester/r1.txt a646001:/home/amartir/main_unix.txt || return 1
mailx -s"Copy of Main_Unix to DSA"
etc
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 08:21 PM
03-18-2004 08:21 PM
Re: Help on Script needed
rcp return code should be ok, but if're doing rsh, a good idea is to make the remote script display a final OK and the local caller grep this output.
For the test :
if [ $? -eq 0 ] ; then
command
else
other_command
fi
is equivalent to
[ $? -eq 0 ] && command || other_command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 08:25 PM
03-18-2004 08:25 PM
Re: Help on Script needed
Sorry
$? is exit error code, and if it is 0 the command properly ENDED.
Boris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 09:27 PM
03-18-2004 09:27 PM
Re: Help on Script needed
rcp -p /sdata/files/cptester/r1.txt a646001:/home/amartir/main_unix.txt && \
mailx -s"Copy of Main_Unix to DSA" elit && \
rm /sdata/files/cptester/r1.txt
The same for the other command.
Or the way mentioned above, using the return code in $? which is 0 (zero) for succesfull commands. You could even do it this way:
if rcp ...
then
mailx ...
rm ...
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 09:30 PM
03-18-2004 09:30 PM
Re: Help on Script needed
rcp -p /sdata/files/cptester/r1.txt a646001:/home/amartir/main_unix.txt && mycommand
If "mycommand" needs to be several commands you can put them in braces as in
rcp -p /sdata/files/cptester/r1.txt a646001:/home/amartir/main_unix.txt && {
mailx .....
rm ....
etc ...
}
The opposite of && is ||
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2004 05:24 PM
03-21-2004 05:24 PM
Re: Help on Script needed
#!/bin/sh
HOST=a646001
rcp -p /sdata/files/cptester/r1.txt $HOST:/home/amartir/main_unix.txt
OK=`remsh $HOST ls /home/amartir/main_unix.txt | wc -l`
if [ "$OK" -eq 1 ]
then
# ur commands
elif
# ur commands
fi
So try the above and make sure copy is done and use the number of files copied as input to ur if statement