#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2014
    Posts
    1
    Rep Power
    0

    shell script called from another shell script with space-seperated parameters fails


    Hello.

    We've a script (script 1) that calls another script (script 2), which it expects to be passed in enclosed in quotes.

    Complications ensue as script2 also takes a number of parameters, some of which are space-seperated strings and another is a sql script.

    This causes script1 to fail.

    Running script2 in isolation works as expected.
    Script1 works when script2's arguments don't have any space seperated strings.

    Behold:

    Code:
    <script1> "<script2 -s "ExchangeRates" <sqlscript.sql>"
    works as expected.

    However:

    Code:
    <script1> "<script2 -s "Exchange Rates" <sqlscript.sql>"
    fails with:

    SP2-0734: unknown command beginning "Rates" @/h..." - rest of line ignored.

    i.e. it treats "Exchange" and "Rates" as two seperate strings.

    So, I tried escaping the spaces:

    Code:
    <script1> "<script2 -s \"Exchange Rates\" <sqlscript.sql>"
    But get exactly the same problem. I can imagine the solution to this is probably staring me in the face and amazingly simple, but I can't see it.

    Any suggestions gratefully recieved.

    Thanks
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    867
    Rep Power
    391

    Cool


    Try adding single quote:
    Code:
    <script1> "<script2 -s \"'Exchange Rates'\" <sqlscript.sql>"

IMN logo majestic logo threadwatch logo seochat tools logo