Solved

copy a file slowly and catch an error when fails on unix

Posted on 2009-07-13
4
232 Views
Last Modified: 2013-12-26
There is a production mainframe job that copy a file between 2AM to 2:30AM on Unix.  Sometimes, the job fails without giving out any error.  

I would like to mimic the copy to find out the error.  So, I am thinking to schedule a unix job to copy a small file ( or ftp a file or something similar) between 2AM to 2:30AM.  I don't want to copy a large file though for 30 minutes.  Is there a way to consistently copy a small file over and over again or copy a small file slowly?  What is the command to catch error message when error occurs?

Thanks.
0
Comment
Question by:ewang1205
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 350 total points
ID: 24841080
if you copy file with command cp then you can always check command exit code:

cp file1 file2

if [ $? -EQ 0 ]
then
    echo successful
else
     echo there was an error
fi
0
 

Author Comment

by:ewang1205
ID: 24841123
Can I echo the error?  Thanks.
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24841139
Well, if there is an error then the command / tool should produce the error message.
0
 
LVL 61

Assisted Solution

by:gheist
gheist earned 150 total points
ID: 24861075
> Can I echo the error?

echo $?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET how to use the Vertical ScrollBar 5 90
ODBC Connection Logging, ADO.NET 6 56
has77  challenge 9 72
how to split multiple lines delimiter : 8 79
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now