Monday, 30 September 2013

How can I catch exception on bash file exit unnormally?

How can I catch exception on bash file exit unnormally?

Here I get a bash file b.sh:
#!/bin/sh
if [ ! -f somefile.txt ]; then
..................
fi
in the bash file ,I try to check whether somefile called "somefile.txt"
exist, if not, I would consider it as an error and exit.
And I run this bash file in c++:
::system("sh b.sh")
What should I fill in the "..............." in that bash file and what
should I do in c++ code to catch exception when the "somefile.txt" is not
found.

No comments:

Post a Comment