Find the answer to your Linux question:
Results 1 to 4 of 4
Hello all, I have written Two scripts as Follows First script name- input #!/bin/sh #Variable Declaration Tv=pinnacle FT=Europe server=192.168.0.5 second Script name - output #!/bin/sh echo " My tv is ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    45

    Thumbs up variables From One Script to Another script

    Hello all,

    I have written Two scripts as Follows

    First script name- input

    #!/bin/sh

    #Variable Declaration

    Tv=pinnacle
    FT=Europe
    server=192.168.0.5

    second Script name - output

    #!/bin/sh

    echo " My tv is - $Tv"
    echo " My Ft is - $FT"
    echo " MY server is -$server"

    My problem is - when i execute second script name output ...echo command showing blank or new line .

    Requirement - I need to take all the variable inputs from script one ,execute in second script.( it mean when i do ./output it must echo all the declaration)

    Is this Possible?
    If YES how ?
    If NO , what is the alternate Solution ?

    Please help
    Thanks

  2. #2
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    Source the file with the declarations using the "." command.

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Posts
    20
    yeah, that means in output file, put this line at the beginning:

    Code:
    source /path/to/input

  4. #4
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Either source one script into another, or pass the relevant variables as parameters and reference them positionally on the second script ($1...).

Posting Permissions

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