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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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
var=$(1st perl script) where script prints val to current env and is captured in $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.