Solved

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ORA-01403: no data found 43 82
bigDiff challenge 17 75
only14 challenge 19 63
modThree challenge 4 64
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

19 Experts available now in Live!

Get 1:1 Help Now