Hi all,
I'm trying to test for a non-zero exit response from a command in a shell script, but pretty transparently.
Here's the English syntax of what I want to do:
1. Copy stuff to stuff2
2. If the copy doesn't work, report an error and end the script
3. If it works fine, then keep on going.
Now this works OK:
The problem is that I can't get rid of having to do something if it's OK. Simply putting then and then right on to else gives a script error.
Better would be to test for the non-success of the copy, i.e.:
But this doesn't work.
Anyway, any ideas?
I'm trying to test for a non-zero exit response from a command in a shell script, but pretty transparently.
Here's the English syntax of what I want to do:
1. Copy stuff to stuff2
2. If the copy doesn't work, report an error and end the script
3. If it works fine, then keep on going.
Now this works OK:
code:<HR>Code:#!/bin/sh<P>if cp stuff stuff2 then echo else echo copy failed exit 1 fi<P>echo moving on with the script<P>
The problem is that I can't get rid of having to do something if it's OK. Simply putting then and then right on to else gives a script error.
Better would be to test for the non-success of the copy, i.e.:
code:<HR>Code:#!/bin/sh<P>if !(cp stuff stuff2) then echo didn't work exit 1 fi
But this doesn't work.
Anyway, any ideas?