Results 1 to 3 of 3

Thread: calling a bash script ( with two arguments ) from a bash script

  1. #1
    Join Date
    Aug 2008
    Beans
    16
    Distro
    Ubuntu 9.10 Karmic Koala

    calling a bash script ( with two arguments ) from a bash script

    Greetings,

    I have a slight problem, and I am unable to find a solution to it, so any help here would be greatly appreciated...

    I have written a compiling script which simply takes two parameters ( sourcefile name, and outputfile name ), this works fine.

    On top of this I have written another small script which compiles some files and then links them with the required parameters, the problem arises when I call my original 'compiling' script.

    Code:
    sh /home/dev/scripts/comp "sourceFile.c outputFile.o"
    This runs the script, but passes the whole string ( "sourceFile.c outputFile.o" ) as one parameter, but I want to pass this as two arguments. I've tried putting them into vars and seperating the vars but to no avail. Is this possible?

    To elaborate: The compile script takes the two arguments 'sourceFile.c' and 'outputFile.o' and runs
    Code:
    gcc -c /home/dev/source/sourceFile.c -o /home/dev/o/outputFile.o
    So essentially its just filling in the paths for me.

    Thanks in advance

  2. #2
    Join Date
    Jul 2009
    Location
    London
    Beans
    1,480
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: calling a bash script ( with two arguments ) from a bash script

    Code:
    sh /home/dev/scripts/comp sourceFile.c outputFile.o
    or if either of your files had spaces in their names then enclose each in quotes:
    Code:
    sh /home/dev/scripts/comp "sourceFile.c" "outputFile.o"

  3. #3
    Join Date
    Aug 2008
    Beans
    16
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: calling a bash script ( with two arguments ) from a bash script

    . Thoguht I tried that. God I'm such a lemon.

    Thanks DaithiF

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •