- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Return Value of cp command
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
Discussions
Discussions
Discussions
Forums
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
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
тАО05-18-2005 05:19 AM
тАО05-18-2005 05:19 AM
Return Value of cp command
A program is getting a return value of "1" although I can see that the copy does take place.
The man page for cp does not even mention a return value. Is there one?
Should I presume that a "1" is the same as a "0"?
Thanks!
Brad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2005 05:30 AM
тАО05-18-2005 05:30 AM
Re: Return Value of cp command
Do this as a test:
cp myfile myfile2
echo ${?}
That should be zero.
Now:
cp myfilesdoesnotexist myfile2
echo ${?}
You should get a non-zero exit status.
I would test the BASIC system command by creating a small script that does an explicit exit 0, exit 1, etc. to see what value the BASIC program actually sees. In a few cases, when making system() calls from other languages, I had to do things like
cc = status / 256 or cc = status MOD 256 to get the "real" value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2005 05:41 AM
тАО05-18-2005 05:41 AM
Re: Return Value of cp command
A typical Business BASIC scall can have an optional "ERR=lineref" parameter so that the BASIC can do a goto lineref if an error is detected:
status% = scall("cp myfile myfile2",err=jumpout)
....
....
jumpout:
bad% = 1
This may work for you even if the return value from scall() is unreliable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2005 05:43 AM
тАО05-18-2005 05:43 AM
Re: Return Value of cp command
-rw-r--r-- 1 root bin 2018 Feb 17 16:03 zizi
ant:/home/vbe $ cp zizi zozo ;echo $?
0
ant:/home/vbe $ cp zaza zozo ;echo $?
cp: cannot access zaza: No such file or directory
1
ant:/home/vbe $
When works it does return 0....
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2005 05:58 AM
тАО05-18-2005 05:58 AM
Re: Return Value of cp command
It looks very silly after A. Clays post...
I was on the way to reply when someone entered my office and started to ask all sorts...
I didnt realize the time past when I pressed submit...
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2005 06:06 AM
тАО05-18-2005 06:06 AM
Re: Return Value of cp command
I say this because this program runs once a day and usually does fine. What I've done for a workaround is simply wait 1 second and then retry the copy; if the copy fails 4 times in a row then I issue an error message and go on my way.
Thanks to both of you for your help.
Brads