Retrieve the value of environment variable in shell script which called from crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Retrieve the value of environment variable in shell script which called from crontab
# 1  
Old 08-03-2010
Retrieve the value of environment variable in shell script which called from crontab

There are two files one is shell script (sample.sh) and another is configuration file (sampl_conf.cfg)

configuration file contains one variable $FTP_HOME. the value of this variable vaires for user to user. If user is say jadoo then value is /home/jadoo/ftp/, for user1 - /home/user1/ftp. The value can be seen at command prompt by typing "echo $FTP_HOME".

In shell script $FTP_HOME variable is used to find out some old file in that path (/home/jadoo/ftp).

Shell scripts reads the configuration file line by line and assing $FTP_HOME variable to another variable say "path"


Code:
#!/bin/sh........... path=`echo $LINE | cut -d" " -f1` duration=`echo $LINE | cut -d" " -f2` filename=`echo $LINE | cut -d" " -f3` path="$path"path=`eval echo $path` if [ "$filename" != "" ] ; then `find $path/$filename -type f -mtime $duration >> $tmpfile;`
Now find should search mentioned file for specific duration in $FTP_HOME directory, but it unable to replace the $FTP_HOME variable by its value.
below error displays on terminal

find: stat() error /log*: No such file or directory

Sample configuration file


Code:
$FTP_HOME +15 log*

Shell script is called through crontab

Please help me on this. thanks in advance.



Moderator's Comments:
Mod Comment How is this a different question to your other post?

Last edited by Scott; 08-03-2010 at 07:13 AM.. Reason: Closed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to pass the config file lines as variable on the respective called function on a script

I want to make a config file which contain all the paths. i want to read the config file line by line and pass as an argument on my below function. Replace all the path with reading config path line by line and pass in respective functions. how can i achieve that? Kindly guide. ... (6 Replies)
Discussion started by: sadique.manzar
6 Replies

2. Shell Programming and Scripting

Passing variable from called script to the caller script

Hi all, Warm regards! I am in a difficult situation here. I have been trying to create a shell script which calls another shell script inside. Here is a simplified version of the same. Calling Script. #!/bin/ksh # want to run as a different process... (6 Replies)
Discussion started by: LoneRanger
6 Replies

3. Shell Programming and Scripting

DBUS_SESSION_BUS_ADDRESS for script called from crontab.

Hi, I'm writing a Bash script for wallpaper clocks which works fine on the command line but needs to be run every minute from a crontab entry so the time gets changed on the wallpaper (the wallpaper gets rebuilt every minute so the current weekday, date, month, hour, and minute become part of... (4 Replies)
Discussion started by: gencon
4 Replies

4. Shell Programming and Scripting

Can a shell variable be called in a cobol program

Hi All, I have a file which sets all the variables on unix , based on the hostname. Currently these variables are hardcoded in the cobol programs.I was wondering if unix variables can be used in Cobol programs ? Example : I have a variable $SHTEMP which is set based on the following : Prod... (2 Replies)
Discussion started by: nua7
2 Replies

5. UNIX for Dummies Questions & Answers

How to retrieve the value of variable in shell script which is called by crontab

There are two files one is shell script (sample.sh) and another is configuration file (sampl_conf.cfg) configuration file contains one variable $FTP_HOME. the value of this variable vaires for user to user. If user is say jadoo then value is /home/jadoo/ftp/, for user1 - /home/user1/ftp. The... (4 Replies)
Discussion started by: jadoo_c2
4 Replies

6. Shell Programming and Scripting

environment variable in shell script called through crontab

Please help me on below.. https://www.unix.com/shell-programming-scripting/141533-retrieve-value-environment-variable-shell-script-called-crontab.html#post302442024 I'm still here. I can still see you! (0 Replies)
Discussion started by: jadoo_c2
0 Replies

7. Shell Programming and Scripting

Setting environment variable using shell script

Hi All, I'm trying to write an menu driven program to automate some functions which involve loging to multiple hosts. The hosts can differ for every use, so I thought I would use an config file to get the hostnames. Now I need to set those values in the config file to environment variable to... (6 Replies)
Discussion started by: arun_maffy
6 Replies

8. Shell Programming and Scripting

Retention of Variable Value when a script is called by different processes in parallel- Linux 2.6.9

Hi, I have a generic FTP script which will be called by 28 different processes in parallel (through a GUI tool) may or may not be at the exact moment (there could be a delay of about a minute or so). ./FTP.ksh 1 (1 through 28) This script after importing file from remote m/c... (1 Reply)
Discussion started by: dips_ag
1 Replies

9. Shell Programming and Scripting

Setting environment variable on a remote solaris machine using shell script

Hi, I am trying to set environment variable on a remote machine. I want to do it by running a shell script Here's what I am doin rsh <remote-hostname> -l root "cd /opt/newclient; . ./setp.sh" In setp.sh, I have ############################# cd ../newlib; export... (1 Reply)
Discussion started by: eamani_sun
1 Replies

10. Shell Programming and Scripting

problem in getting the path of environment variable set in bashrc in my shell script

hi all i have joined new to the group. i have set an variable in my bashrc file. .bashrc PROGHOME=/home/braf/braf/prog export PROGHOME but while using it in my shell script its path is not taken and i had to explicitly give the export command to set the path. in my script... (8 Replies)
Discussion started by: krithika
8 Replies
Login or Register to Ask a Question