Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Source command in perl script

by Utilitarian (Vicar)
on Oct 20, 2011 at 08:45 UTC ( #932589=note: print w/replies, xml ) Need Help??

in reply to Source command in perl script

What's wrong with running it in the apropriate shell?
ie. /bin/sh /home/db2inst1/sqllib/db2profile

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Replies are listed 'Best First'.
Re^2: Source command in perl script
by bannaN (Acolyte) on Oct 20, 2011 at 09:08 UTC
    Have the script like this?
    `/bin/sh /home/db2inst1/sqllib/db2profile`; system("db2 terminate");
    If i try to run something like this, the db2 command will not be recognized.
    Error: "Can't exec "db2": No such file or directory"

    So if i understood you correctly that doesnt work for some reason. As you may have understood i am not that into the logic of how different shells acquire their environment, and pass it on.
    Am i right in the assumption that the system command will fork and inherit the environment from the perl script?
    If i am, the question still stands, how can i make the perl script acquire the db2 environment
      A parent process cannot inherit from a process it spawns.

      You can however set the environment within the Perl script and then the system call will inherit it or you could run the db2profile scipt prior to running the Perl script and then everything would inherit it.

      Rewriting as Perl

      $ENV{PATH}="$ENV{PATH}:/opt/db2/bin" ...
      Or calling everything from a shell script...
      #!/bin/sh . /home/db2inst1/sqllib/db2profile /home/db2instl/bin/ # Or whatever the script is called

      print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932589]
[Cosmic37]: Fast Artificial Neural Network (FANN) is cross-platform open source programming library for developing multilayer feedforward Artificial Neural Networks
[corenth]: @stuff was pretty big. I think it grew to about 8000.
[corenth]: each element was several three + element references
[corenth]: That FANN thing sounds like something I
[Cosmic37]: When I say I like LGPL what I mean is that I like the GPL aspect. I am a fan of Rishard Stallman and the Free Software Foundation but I wish I could be more virtuous... self-flagellates
[corenth]: . . . I'd like to play with
[corenth]: I'm a pragmatic free-software advocate. I'll play in a walled sandbox when I need to.
[erix]: hm, there's a FANN perl module - looks a bit old
[Cosmic37]: I'm afraid I don't know the answer to your map question...... what were the references too?

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2018-02-20 18:23 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.