Does 2 scripts running at same use a variable with same name conflict?
All,
I have a Bash SFTP script that I run and before I would hardcode the file name.
I recently decided to put the filename in a variable called $FILENAME.
I had 2 scripts that run at the same time and it seems like in the middle of one of the scripts the variable called the other scripts $FILENAME for my put command.
So, my question is, aren't the variables in a script supposed to be local to the script? At the beginning of the script the variable was fine, but then the put command put the wrong file. See below, the variable $FILENAME switched from CQ12345 to CT12345 in the middle of the script. The other script I run at the same time's variable in CT12345
Script they both run except the FILENAME variable is different:
Log
Last edited by markdjones82; 11-30-2010 at 01:13 PM..
Reason: Edited post to make it make more sense
Do you have glob turned off? Are the filenames on disk really CQ******?
Normal syntax would be
to find files starting with "CQ"
or CQ?????? to find a file starting with CQ that has any six characters after CQ
Jim, sorry I shouldn't have used **** I was just using that as a comment out for the rest of the characters of the file name. It is something like CQ12345 and the other file is CT12345. My SFTP scripts pull these files from the same directory, but both are separate scripts. One has filename set to CQ12345 and the other CT12345. They execute on the same cron schedule.
If you look at the log, it finds the CQ file, but then when it ran the put command it used the CT file name instead of the CQ file name. Maybe I had it hardcoded still at that portion instead of the $FILENAME as I copied it from my original script and then edited? Could be programmer error, but i'm pretty sure I had $FILENAME right after the put command when I looked it. I know for sure it has it now.
I'm not sure how to check if glob is turned off/on. It is running RHEL 5.5 so whatever the default for that is.
I just wanted to be sure that the variable should stay local to that script. That assumption should be correct right? I can run some tests with echo when I get back in office.
---------- Post updated 12-01-10 at 10:43 AM ---------- Previous update was 11-30-10 at 01:08 PM ----------
Quote:
Originally Posted by jim mcnamara
Do you have glob turned off? Are the filenames on disk really CQ******?
Normal syntax would be
to find files starting with "CQ"
or CQ?????? to find a file starting with CQ that has any six characters after CQ
I just realized the problem. The temp file I wrote the SFTP commands to that the sftp -b would read from had the same name. So, when they executed at the same time. It overwrote it with the other file names.
Programmer error!
Last edited by markdjones82; 11-30-2010 at 01:19 PM..
Hi,
I need a script (ksh) on ServerAdmin that will run an archive scripts from different several Servers through ssh. The problem is that how can i switch user when before running the archive script. I already configured password-less connection on the servers.
server 1... (1 Reply)
Hi to All,
Please find below details.
file_config.config
export file1_status="SUCCESS"
export file2_status="SUCCESS"
file_one.sh
I am calling another two shell script from these script. I need to pass individual two script status (If it's "FAILED") to file_main.sh.
file_main.sh
I... (2 Replies)
I need to run a script (from cron) that runs a second script.
What worries me is that second script, when run from bash, upon finishing doesn't return to bash unless I press the 'Enter' key.
I presume that's because last command in that script ends with &
Could that be a problem for cron?... (2 Replies)
Hi,
I am new to use minicom. I want script to run on minicom with username and password as automated.(Expect). please could anyone suggest the sample code for it.
Thanks in advance (2 Replies)
I would like to run two scripts using cron one immediately after the other. Is it enough to put them one after another in the cron file to run at the same time, or will this cause them to run concurrently? (4 Replies)
Hi all,
I have set up a cron job which calls another shell script shell script which in turn calls a Java process. The cron tab looks so.
0,30 7-18 * * 1-5 /u01/home/weblogic/brp/bin/checkstatus.sh >> /u01/home/weblogic/logs/checkstatus.log
The checkstatus.sh scripts looks like this.
... (4 Replies)
Hello
I have a script that has 2 scripts that must be executed one after the other.
however, when I run the script, the 2 sub-scripts are run in parallel.
any idea how to fix this without using sleep command?
thank you (7 Replies)
Hi All,
Am using the below command to start my application using the root user
su - bin -c "/home/bin/test/start.sh"
but am getting the error becaue i have set some environment varibales in bin .profile
when i execute the command start.sh by logging directly into bin account it's... (8 Replies)
Hello everybody,
I'm trying to run a shell script in crontab file. But anyhow it's not getting executed. Following is the command that I've used in crontab.
30 07 * * * . ./.cronprofile;/om/reports/reportscripts/jitu/prod/prd_pre_to_post.sh
35 11 * * * .... (3 Replies)
I have created a Bourne shell script that helps with metric counting and it has to be run in a ClearCase view. It has been placed in a directory where if User A cd'd to it and runs it, a bunch of errors occur. Because this is a tool that several users would want access to and the program assumes... (2 Replies)