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.
I'm a Linux newbie, so I'm probably overlooking something obvious. I'm running Ubuntu 8.04 and trying to send updates to a SOLR server via a bash script.
Problem is, when I call the import script it gives me the error message:
You need to set the SOLR_HOME environmental variable before running this script.
Now, I can set SOLR_HOME using the export command, but the bash script still can't see it. The code in the bash script generating the error is this:
if [ -z "$SOLR_HOME" ]
echo "You need to set the SOLR_HOME ... "
Strangely, the import script does run (without warnings) if I call it using a Perl script with the line:
So: Why would a child process not see an environment variable exported by its parent process? And why would commands issued from the command line fail while the same commands sent from a Perl script succeed?
After that, I can enter
and see the value I've just established; or I can enter env and see SOLR_HOME in the list. The script warns me to set the SOLR_HOME environment variable anyway.
I run the import script with the command:
the same command without "sudo" doesn't work: the shell just sits for a minute and then gives me another prompt. No warnings about permissions or anything. This is also puzzling behavior, but I'm not sure it's related.
So, that's the point: the "sudo" command does not preserve the environment, that is, it does not preserve variables values.
Give a look at the sudo manpage, the -E option and "SECURITY NOTES" describe how to deal with this. You can change your sudoers file to preserve the environment, or you can insert your environment modifications in a script, say do_all.sh, that called with 'sudo do_all.sh' changes the environment and eventually calls ./import.sh