Sponsored Content
Top Forums Shell Programming and Scripting Does 2 scripts running at same use a variable with same name conflict? Post 302475917 by markdjones82 on Tuesday 30th of November 2010 09:39:47 AM
Old 11-30-2010
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:
Code:
FILENAME=CQ12345
ARCHLOC=
LOGFILE=
GETDATE=`date`


#    echo start date to log

echo "Started script at $GETDATE" >> $LOGFILE

if [ "$(find $ORIGLOC/$FILENAME -type f)" ]; then

#    List files out to log

echo " The following file was found and is about to be transferred..." >> $LOGFILE

ls -l $ORIGLOC/$FILENAME >> $LOGFILE

#    Copy files to archive location

cp -pv $ORIGLOC/$FILENAME $ARCHLOC >> $LOGFILE

#    Copy files to new location

cd $ORIGLOC
echo cd INBOUND > /tmp/sftp.sftp
echo put $FILENAME >> /tmp/sftp.sftp
echo bye >> /tmp/sftp.sftp
sftp -b /tmp/sftp.sftp $DESTUSER@$DESTSERV >> $LOGFILE

Log
Code:
 The following file was found and is about to be transferred...
-rwx------ 1 root root 103675 Nov 26 11:56 /CQ12345
`CQ12345' -> `CQ12345'
sftp> cd INBOUND
sftp> put CT12345
Uploading CT12345 to /INBOUND/CT12345
sftp> bye


Last edited by markdjones82; 11-30-2010 at 01:13 PM.. Reason: Edited post to make it make more sense
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Running scripts from home

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)
Discussion started by: mastachef
2 Replies

2. Shell Programming and Scripting

Running scripts through cronjob.

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)
Discussion started by: jitu.jk
3 Replies

3. Shell Programming and Scripting

Running scripts via su

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)
Discussion started by: ravi.sri24
8 Replies

4. Shell Programming and Scripting

sequential running for 2 scripts

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)
Discussion started by: melanie_pfefer
7 Replies

5. Shell Programming and Scripting

Running scripts within scripts from cron

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)
Discussion started by: sirbrian
4 Replies

6. Shell Programming and Scripting

Running 2 scripts one after the other using cron

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)
Discussion started by: 3210
4 Replies

7. Shell Programming and Scripting

running scripts in minicom

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)
Discussion started by: vanid
2 Replies

8. Solaris

running scripts from cron

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)
Discussion started by: orange47
2 Replies

9. Shell Programming and Scripting

Change Variable Value from Multiple Scripts and Use these Variable

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)
Discussion started by: div_Neev
2 Replies

10. UNIX for Dummies Questions & Answers

Running scripts from different server

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)
Discussion started by: chococrunch6
1 Replies
sftp-server(1M)                                           System Administration Commands                                           sftp-server(1M)

NAME
sftp-server - SFTP server subsystem SYNOPSIS
/usr/lib/ssh/sftp-server DESCRIPTION
sftp-server implements the server side of the SSH File Transfer Protocol as defined in the IETF draft-ietf-secsh-filexfer. sftp-server is a subsystem for sshd(1M) and must not be run directly. There are no options or config settings. To enable the sftp-server subsystem for sshd add the following to /etc/ssh/sshd_config: Subsystem sftp /usr/lib/ssh/sftp-server See sshd_config(4) for a description of the format and contents of that file. There is no relationship between the protocol used by sftp-server and the FTP protocol (RFC 959) provided by in.ftpd. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. FILES
/usr/lib/sftp-server ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWsshdu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
sftp(1), ssh(1), ssh-add(1), ssh-keygen(1), sshd(1M), sshd_config(4), attributes(5) To view license terms, attribution, and copyright for OpenSSH, the default path is /var/sadm/pkg/SUNWsshdr/install/copyright. If the Solaris operating environment has been installed anywhere other than the default, modify the given path to access the file at the installed location. AUTHOR
Markus Friedl SunOS 5.10 30 Jul 2003 sftp-server(1M)
All times are GMT -4. The time now is 03:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy