Professional Web Applications Themes

passing variables from on script to another - Linux / Unix Administration

How do I pass variables from one scrip to another. I dont want to call the second script from the first with the variables on the 'command l I really want to set an environment variable in script1 and pick it up in script2, but I can't get it to work script1= ----------------------------------------------- dk=derrick echo $dk script2 ----------------------------------------------- script2 = ----------------------------------------------- echo $dk script 1 echos derrick, but script 2 does not?? thanks derrick...

Sponsored Links
  1. #1

    Default passing variables from on script to another

    How do I pass variables from one scrip to another.

    I dont want to call the second script from the first with the variables on
    the 'command l

    I really want to set an environment variable in script1 and pick it up in
    script2, but I can't get it to work

    script1=

    -----------------------------------------------
    dk=derrick
    echo $dk
    script2
    -----------------------------------------------

    script2 =

    -----------------------------------------------
    echo $dk


    script 1 echos derrick, but script 2 does not??

    thanks

    derrick


    Sponsored Links
    Derk Guest

  2. #2

    Default Re: passing variables from on script to another

    "Derk" <gov.uk> writes: 

    If script 1 calls script 2, then add "export dk" and it will work.

    If script 1 does not call script 2 (i.e., they're both called by some
    other process, and neither calls the other, or script 2 calls script
    1), then it cannot be done.

    --
    James Carlson, KISS Network <com>
    Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084
    MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
    James Guest

  3. #3

    Default Re: passing variables from on script to another

    Derk wrote: 
    examples/references:
    $ cat first
    foo=foo
    $ cat second
    #!/bin/sh
    echo foo="$foo"
    $ (unset foo; . first; . second)
    foo=foo
    $ (unset foo; . first; export foo; ./second)
    foo=foo
    $ ed first
    8
    s/^/echo /
    $a
    echo export foo
    ..
    w
    29
    q
    $ cat first
    echo foo=foo
    echo export foo
    $ (unset foo; eval `./first`; ./second)
    foo=foo
    $
    sh(1)
    fork(2)

    Michael Guest

  4. #4

    Default Re: passing variables from on script to another

    On 16 Mar 2006 07:28:23 -0500, James Carlson <com>
    wrote:
     

    You could kluge something similar by having some temp file that script 1
    writes, and then script 2 reads it and puts it into its envvar.

    --
    Frank J. Perricone state.vt.us
    IT Manager 802-828-4926 Fax: 802-828-2803
    Vermont Department of Liquor Control http://www.state.vt.us/dlc/
    Frank Guest

  5. Moderated Post

    Default Re: passing variables from on script to another

    Removed by Administrator
    aasim.ajaz@gmail.com Guest
    Moderated Post

Similar Threads

  1. Passing variables from one swf to another
    By chintuChamp in forum Macromedia Flash Flashcom
    Replies: 1
    Last Post: October 20th, 02:48 PM
  2. help passing url variables...
    By matt57017 in forum Macromedia ColdFusion
    Replies: 6
    Last Post: September 14th, 02:08 AM
  3. passing variables from form to php graphics creating script
    By Adam Sargant in forum PHP Development
    Replies: 1
    Last Post: April 18th, 09:14 PM
  4. Variables not passing to mail script
    By Jeff in forum PHP Development
    Replies: 4
    Last Post: October 29th, 12:04 AM
  5. variables, passing again to another.
    By Louie Miranda in forum PHP Development
    Replies: 0
    Last Post: September 25th, 07:46 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139