Which I at first thought had to do with not getting the variable right--- but a little detective work convinced me that what it couldn't find were the two scripts.
IMO you are wrong, if you don't have script in place, the shell script will say
./check.sh: line 3: firstscript: command not found
./check.sh: line 4: secondscript: command not found
IMO you have problem with arguments only, and might be some problems with the absolute path of the first and second script(as other monks mentioned).
generally if you are dealing with filenames in shell scripts, just check it existence before using it for further processing.
you can use something like
True if file exists.
True if file exists and is a regular file.
True if file exists and is readable.
True if file exists and has a size greater than zero.
True if file exists and is owned by the effective user i
True if file exists and is owned by the effective group
and more of this can be seen in your shell manual(the above operators are from bash manual), use those effectively to figure out whether the file exists and continue only in such case. For the script use
True if file exists and is executable.
before calling it from your shell script.
if I write your script (shown in OP), in bash, it will be like
echo -e "received arguments >$*<"
script1='fristscript'; # use absolute path
script2='firstscript'; # use absolute path
if [ -f $filename ] ; then
echo -e "executing scripts $script1, $script2";
if [ -x $script1 ]; then
echo -e "executing $script1..."
echo -e "$script1 not found";
if [ -x $script2 ]; then
echo -e "executing $script2..."
echo -e "$script2 not found";
echo -e "$filename is not readable or doesn't exist";
Hope this helps.
(again the above bash code can be written even more effectively, but that is not the point of discussion)
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] |