Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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
./ line 3: firstscript: command not found ./ 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
-e file True if file exists. -f file True if file exists and is a regular file. -r file True if file exists and is readable. -s file True if file exists and has a size greater than zero. -O file True if file exists and is owned by the effective user i +d. -G file True if file exists and is owned by the effective group +id.
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
-x file 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

#!/bin/bash echo -e "received arguments >$*<" filename=$1; 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..." $script1 $filename else echo -e "$script1 not found"; fi if [ -x $script2 ]; then echo -e "executing $script2..." $script2 $filename else echo -e "$script2 not found"; fi else echo -e "$filename is not readable or doesn't exist"; fi
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.

In reply to Re: perl callable from bash? by targetsmart
in thread perl callable from bash? by hsmyers

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • 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:
    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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (5)
    As of 2020-01-28 19:30 GMT
    Find Nodes?
      Voting Booth?