GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script wanted
Operating System - HP-UX
1846028
Members
3263
Online
110253
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
- 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
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
07-15-2008 12:04 AM
07-15-2008 12:04 AM
script wanted
I have two servers , sometimes they have problem to transfer files ( may be the connection problem ), so sometimes there are some files did not transferred to remote site ( one direction only , from server A to server B ) , so I would like to have a script to check if the files are sucessfully transferred , the condition of the checking is as below :
when found a new .err extension file in /tmp , then wait 5 minutes ( because assume the file transfer need 5 minutes ) , and then check the files in directory /ora in both server are the same or not ( only check the files that are created within 30 minutes because there is another script will copy the file to server B in every 30 minutes ) , if any file in server A have but server B do not , then notify me which file is not transferred , in simply , what I want to check is the files ( created within 30 minutes ) in both server are exist or not when the .err file found , if any transfer problem , then notify me , could provide the script ?
thx
when found a new .err extension file in /tmp , then wait 5 minutes ( because assume the file transfer need 5 minutes ) , and then check the files in directory /ora in both server are the same or not ( only check the files that are created within 30 minutes because there is another script will copy the file to server B in every 30 minutes ) , if any file in server A have but server B do not , then notify me which file is not transferred , in simply , what I want to check is the files ( created within 30 minutes ) in both server are exist or not when the .err file found , if any transfer problem , then notify me , could provide the script ?
thx
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2008 12:12 AM
07-15-2008 12:12 AM
Re: script wanted
Hi,
Just a thought. I am not good at scripting. Trying to give a simple draft. Hope its matching your criteria.
1- Enter IF loop if .err exist
use ls /tmp | grep -i err
2- under IF loop
chk files exists or not on both servers
use -mtime with find.
If yes then
check chksum for both files
If match then all good
If not throw error mail using mailx.
Just a thought. I am not good at scripting. Trying to give a simple draft. Hope its matching your criteria.
1- Enter IF loop if .err exist
use ls /tmp | grep -i err
2- under IF loop
chk files exists or not on both servers
use -mtime with find.
If yes then
check chksum for both files
If match then all good
If not throw error mail using mailx.
Will it remain a personal, if I broadcast it here!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2008 01:37 AM
07-15-2008 01:37 AM
Re: script wanted
What are you using to transfer the files?
If using scp you can capture the return code
EXIT STATUS
0 Operation was successful.
1, 2 Operation resulted in an undetermined error within sshfilecopy.
3 Destination is not directory, but it should be.
4 Connection to host failed.
5 Connection lost.
6 File does not exist.
7 No permission to access file
8 Undetermined error from sshfilexfer.
9 File transfer protocol mismatch.
EXAMPLES
The following example shows how to copy files from your local system to a remote system:
prompt>scp localfile user@remotehost:/dest/
If used in a script after the command capture the error code:
typeset -i RC # Create integer variable
# put at beginning of script
RC=$? # Put immediately after command
Then check the error code:
if [ ${RC} -eq 0 ] ; then
echo "Operation succeeded"
else
echo "There's been an error" | mailx -s "Subject" mail.recipient@somewhere.ca
fi
RC=0 # Reset the variable if you're putting into a loop
I used echo statements to indicate where you'd put the commands you'd like to run after the copy based on the success/failure.
I didn't do a compare of the files after because if SCP has a return code of 0 then the file from the Source is definately on the Destination server.
Note this is KSH script syntax.
What tools do you have available to you to look at the directory contents on the remote server(s)? Can you SSH to/from each server?
If using scp you can capture the return code
EXIT STATUS
0 Operation was successful.
1, 2 Operation resulted in an undetermined error within sshfilecopy.
3 Destination is not directory, but it should be.
4 Connection to host failed.
5 Connection lost.
6 File does not exist.
7 No permission to access file
8 Undetermined error from sshfilexfer.
9 File transfer protocol mismatch.
EXAMPLES
The following example shows how to copy files from your local system to a remote system:
prompt>scp localfile user@remotehost:/dest/
If used in a script after the command capture the error code:
typeset -i RC # Create integer variable
# put at beginning of script
RC=$? # Put immediately after command
Then check the error code:
if [ ${RC} -eq 0 ] ; then
echo "Operation succeeded"
else
echo "There's been an error" | mailx -s "Subject" mail.recipient@somewhere.ca
fi
RC=0 # Reset the variable if you're putting into a loop
I used echo statements to indicate where you'd put the commands you'd like to run after the copy based on the success/failure.
I didn't do a compare of the files after because if SCP has a return code of 0 then the file from the Source is definately on the Destination server.
Note this is KSH script syntax.
What tools do you have available to you to look at the directory contents on the remote server(s)? Can you SSH to/from each server?
The Devil is in the detail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2008 04:35 AM
07-16-2008 04:35 AM
Re: script wanted
Though, as Kevin suggested the evaluation of the SSH command's return code may suffice most of the times,
I have always implemented additionally in my scripts which involve any sort of transfer between hosts (usually by SSH) a postprocessing that compares the check sums or a hash digest taken of the files on the source system with those after successful transfer on the target system.
This is simply comparing two strings of the output from a command like cksum or md5sum for instance.
Most scripting languages also have custom modules with function or method calls for these calculations.
I have always implemented additionally in my scripts which involve any sort of transfer between hosts (usually by SSH) a postprocessing that compares the check sums or a hash digest taken of the files on the source system with those after successful transfer on the target system.
This is simply comparing two strings of the output from a command like cksum or md5sum for instance.
Most scripting languages also have custom modules with function or method calls for these calculations.
Madness, thy name is system administration
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