Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
thanks for u r support,
hope this will explain to u better
when i use this in my perl script,
system("FLEXLM_TIMEOUT =500000");
I am not able to create an env variable by name FLEXLM_TIMEOUT , after running the script , i checked in env , but the environment variable was not there,pls help
That's because system() creates a new sub-shell, same as if you ran a shell prg.
As you (should) know, you can export env vars down a process tree, but not up.
You could tell it to print the value which would enable a a calling shell to use it.
Here, I mean print from the Perl level, not from within the system() cmd.
See http://perldoc.perl.org/functions/system.html
Like I said, you can do it that way, but after a script has finished, the (sub)shell in which it runs is removed/destroyed by the OS.
You can save/print it to a temp file.
What exactly are you trying to achieve?
Well, a prog can only affect it's own env. If you want to share values with other scripts, you can
1. Call other script from yours and pass value as cmd line arg
2. Call other script from yours and export val to new env eg system("export $var && run_new_script");
3. Use temp file
4. Use threads
5. use fork()
6. use shell and capture / fwd val on cmd line eg
#!/bin/bash
var=$(1st perl script) where script prints val to current env and is captured in $var
run_2nd_script $var
7. use a DB
8. use sockets.
As I mentioned above, progs either run in their own env and/or create a new env to output to.
There is not 1 global env shared by all you progs.
Values can be exported 'down' the process tree but not up.
It's a fundamental design thing with Unix.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.