Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Shell script

Hi,
I am missing a small point here and could not figure out the solution
I have to create some enviornment variables in bash
I do the following
1) create a file "script"
2) chmod 755 script
3) edit the file and write the following
PRINTER=PostScript;
export PRINTER
4) ./script
5) set | grep PRINTER gives me nothing...I was expecting the enviornment variable to be set..I donno whats up ?
Thanks
Kapil

Comments

  • Null and VoidNull and Void Member Posts: 1,202
    I don't actually know the answer, but this is a short-term fix:
    [code]
    $ `cat script`
    [/code]
    Yeah, cheesy ;). I had this problem a while ago while writting a script to setup CVS environment variables so that I didn't have to do it manually, I just stuck with that solution.
  • malloc_size_tmalloc_size_t Member Posts: 4
    : Hi,
    : I am missing a small point here and could not figure out the solution
    : I have to create some enviornment variables in bash
    : I do the following
    : 1) create a file "script"
    : 2) chmod 755 script
    : 3) edit the file and write the following
    : PRINTER=PostScript;
    : export PRINTER
    : 4) ./script
    : 5) set | grep PRINTER gives me nothing...I was expecting the enviornment variable to be set..I donno whats up ?
    : Thanks
    : Kapil
    :
    :
    You need to make the script part of your environment like so
    . ./script
    You executed the script, which makes the env variables stick around until
    the script is done. Please note, executing a script and making a script
    part of your environment are not the same thing at all.

  • Jeff P.Jeff P. Member Posts: 196
    : I have to create some enviornment variables in bash

    You could just add this line to one of the bash dotfiles,
    usually either ~/.profile or ~/.bashrc

    export PRINTER=PostScript


  • opensourceopensource Member Posts: 25
    [b][red]This message was edited by opensource at 2002-9-25 20:42:45[/red][/b][hr]
    Try $prompt>env | grep PRINTER

    : Hi,
    : I am missing a small point here and could not figure out the solution
    : I have to create some enviornment variables in bash
    : I do the following
    : 1) create a file "script"
    : 2) chmod 755 script
    : 3) edit the file and write the following
    : PRINTER=PostScript;
    : export PRINTER
    : 4) ./script
    : 5) set | grep PRINTER gives me nothing...I was expecting the enviornment variable to be set..I donno whats up ?
    : Thanks
    : Kapil
    :
    :

  • Andre YoungAndre Young USAMember Posts: 0

    ______ || http://forcoder.org || free ebooks and video tutorials about < Go, C#, PHP, Objective-C, Ruby, Delphi, C, Scratch, MATLAB, PL/SQL, Assembly, Visual Basic, Perl, R, Visual Basic .NET, C++, JavaScript, Swift, Python, Java Crystal, VBScript, Bash, Lisp, ABAP, Dart, Erlang, Logo, SAS, Transact-SQL, D, Hack, Julia, Fortran, Alice, Clojure, Kotlin, Ada, Lua, COBOL, ML, Rust, FoxPro, Prolog, LabVIEW, Apex, Scheme, Awk, Scala, F# /> ____

Sign In or Register to comment.