Find the answer to your Linux question:
Results 1 to 6 of 6
Hi all, I was using a export to export the variable. but each time when i execute the script, my terminal will exit. here is the code file1.sh - contents ...
  1. #1
    Just Joined!
    Join Date
    Aug 2008
    Posts
    49

    export problem???

    Hi all,

    I was using a export to export the variable. but each time when i execute the script, my terminal will exit. here is the code

    file1.sh - contents

    echo the value exported by the shell is $var
    var=newvalue
    export var
    exec /root/file2.sh

    file2.sh - contents

    echo "the value is $var"

    Each time when i execute the file1.sh, my teminal will exit...
    why is this???

  2. #2
    Just Joined!
    Join Date
    Nov 2008
    Posts
    26
    Which shell are you using? Korn? Boune? bash? some other? Anyway, this is a usage of "exec" that I've not encountered, and it's likely the bad guy

  3. #3
    Just Joined!
    Join Date
    Nov 2008
    Posts
    26
    Another possibility (a long shot) ... that script DOES say "exec" and not "exit" - right?

  4. #4
    Just Joined!
    Join Date
    Aug 2008
    Posts
    49
    Hi...

    I am using bash... its "exec" only... if execute
    sh file1.sh

    immediately, it will exit from the current terminal.

  5. #5
    Just Joined!
    Join Date
    Oct 2008
    Posts
    10
    at first sight there is no problem, when you execute "exec", file1.sh finishes and file2.sh starts executing, so it should print "the value is newvalue"

    I have tried it on my machine and it works...

  6. #6
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.
    Quote Originally Posted by dayananda.ms View Post
    ... Each time when i execute the file1.sh, my teminal will exit...
    How are you causing the execution of file1.sh ? Show us the exact control statement you use ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

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