Solved

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

Posted on 2009-07-13
4
237 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 62

Assisted Solution

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

echo $?
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

810 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