The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > HP-UX
.
google unix.com



HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
executing script by cron doesnt give me expected result anchal_khare UNIX for Advanced & Expert Users 1 09-12-2007 08:07 AM
executing a SQL query in shell script lijju.mathew Shell Programming and Scripting 1 05-17-2007 11:29 AM
Executing a Shell Script igandu UNIX for Dummies Questions & Answers 4 08-17-2006 10:29 AM
Shell script is not executing dreams5617 UNIX for Advanced & Expert Users 5 08-20-2004 11:45 AM
Executing shell script with xp_cmdshell gerald_agoi UNIX for Advanced & Expert Users 2 10-10-2001 04:24 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-15-2006
abNORMal abNORMal is offline
Registered User
  
 

Join Date: May 2004
Posts: 12
executing shell script from the cron

This isn't the usual problem that a shell script runs from the command line and not the cron. It's a little different.

Among other things, the shell scrip executes my .profile to set a bunch of variables. It then does an env to ensure that it ran OK.

There are echos in the shell script and the .profile. All this gets logged.

The shell script (simplified) looks like this:

echo Start of shell script
echo
.
.
.
/home/me/.profile

echo Results of env =
env

echo
echo End of shell script

The log (simplified) looks like this:

Start of shell script

----------- (these echos are from the .profile)
profile started

variables a b c x y z set
a=yes
b=yes
c=yes
x=yes
y=yes
z=yes

profile ended
------------------------

Results of env =

a=no
b=yes
c=no
--------

end of shell script


I can see from the log that it is executing the correct .profile, however, the variables set in the .profile aren't "retained".

If I change the command to :

. /home/me/.profile
^
Note: added . space

everthing runs fine.

So what's does the . space do that makes it work?
  #2 (permalink)  
Old 06-15-2006
steweston steweston is offline
Registered User
  
 

Join Date: May 2006
Location: Vancouver, BC
Posts: 11
sourcing a file

NORM,

. file
is known as sourcing a file.

It will pull any env settings, or variables set within the file into the current shell.

[ Normal behaviour is for a child process to inherit from a parent, not the other way around, which is why you lost your settings previously]



steve
  #3 (permalink)  
Old 06-15-2006
abNORMal abNORMal is offline
Registered User
  
 

Join Date: May 2004
Posts: 12
Thanks, Steve. (Didn't know about inheritance)
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0