Script not running properly


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script not running properly
# 1  
Old 02-22-2008
Script not running properly

I created a script before which was this :-

Code:
 cd /mike/dataxfer
     for dir in *; do
     if [ -d ${dir}/priceops ]; then
     ssh -l abc nissan "mkdir -p  /mike/web/$dir"
     scp -r ${dir}/priceops nissan:mike/web/${dir}/
    fi
    done

exit 0

This script worked fine for me with no problem. It will do a recursive search if that priceops directory exist then it will create the parant directory and thew priceops folder in the remote machine (nissan) and then will do a scp to copy all the contents of that priceops folder. It worked fine.

But now they change the priceops folder to( Price Shops ) folder. so i changed my script to this:-

Code:
  PRICE_SHOPS="Price Shops"
     cd /mike/dataxfer
     for dir in *; do
     if [ -d ${dir}/$PRICE_SHOPS ]; then
     ssh -l abc nissan "mkdir -p /mike/web/$dir"
     scp -r ${dir}/$PRICE_SHOPS nissan:/mike/web/${dir}/
    fi
    done

exit 0

and it is not working for me neither i am getting any errors also. when i type
./file_transfer1.sh
to run my script i dont get any response of files transfered or any errors. What is wrong or anyone care to help?

Thanks
# 2  
Old 02-22-2008
Ok I fixed the problem. But now when i run my script i get :-

saloo @ supra: ./file_transfer1.sh
./file_transfer1.sh[39]: ssh: not found.
# 3  
Old 02-22-2008
You need to provide the absoulte path to ssh and scp or put the directory in which they reside into your PATH.

Option 1 (assuming that scp and ssh are in /usr/local/bin):
Code:
PATH=${PATH}:/usr/local/bin

Option2 (assuming that scp and ssh are in /usr/local/bin):
Code:
/usr/local/bin/ssh -l abc nissan "mkdir -p  /mike/web/$dir"

# 4  
Old 02-22-2008
i dont understand. IN my first script i did'nt had any problems. But i just changed the folder and then problem presist.

Can i ask you that how can i find the patth to ssh or scp?

Thanks for your help bro.
# 5  
Old 02-22-2008
Thanks dangral It worked for me /usr/local/bin

Thank you
# 6  
Old 02-22-2008
Actually the problemn seems to be the space in rthe PRICE_SHOPS var.

Use ${PRICE_SHOPS} than it will also work.

The variable gets expanded and then the interpreter hangs on the space.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Process Instance not running properly.

I have run 10 instances of the process eg, process name is BG nohup /WP01IRB1_irbapp/IRBWPROD/RB/bin/BG -c 1 -t 23 -a '-caTop TESTBILLCYCLE='5FEB13_81PT19NPT''>a.txt & nohup /WP01IRB1_irbapp/IRBWPROD/RB/bin/BG -c 2 -t 23 -a '-caTop TESTBILLCYCLE='5FEB13_81PT19NPT''>b.txt & nohup... (3 Replies)
Discussion started by: ankitknit
3 Replies

2. Shell Programming and Scripting

Script does not run properly

Hello everybody Im learning bash scrpting language and im making a script that read a file line by line and it does a comparison if in a line start with a letter or number and it will delete every ones that start with a letter. But im getting some errors First of all, this is the script's... (5 Replies)
Discussion started by: alienrunes
5 Replies

3. Shell Programming and Scripting

Shell script not working properly

Hello, i have below shell script to process ftp get from server and create file list afte finish. this shell scipt has 6 parameter input. unfortunately, it is only working to get the file and terminated before creating file list. please help. thanks, #!/bin/ksh ## example usage :... (3 Replies)
Discussion started by: daryatmo
3 Replies

4. Shell Programming and Scripting

script line not working properly

Hi , I am using the below command in script. $_IDLETIME is returning value if i execute the script manually. sar > $_LOCATION/sar.txt _IDLETIME=`tail -2 $_LOCATION/sar.txt | head -1 | tr -s ' ' ' ' | cut -d ' ' -f8 | cut -d '.' -f1`; if But it s not returning any value if it put the... (3 Replies)
Discussion started by: ahamed
3 Replies

5. Shell Programming and Scripting

Shell Script Email not working Properly

Hi GURU's, I'm using a Shell Script to send email's as an attachment. I'm Storing the email address in a table and catching in a variable. MAILLIST=`noarg sqlplus -s $OraUsr << EOF set heading off set feedback off set echo off SELECT email_ids FROM tpemail_table WHERE... (9 Replies)
Discussion started by: karthikraj
9 Replies

6. Homework & Coursework Questions

Script does not execute properly

I am trying to create a Unix script that when ran will provide a veiw of the files of the week that the user inputs, I have this one down. Then I would like them to be able to type in one of the files that is in that week and it displays that file. The script that I have keeps looping the week... (4 Replies)
Discussion started by: Goob
4 Replies

7. Shell Programming and Scripting

Script not running properly when run from Crontab

Hi I am a novice Linux/Perl user and am struggling to overcome what I am sure is a simple problem. I am using a perl program to create a shell script daily containing between 10 and 30 "at -f" commands for the same day. Then I change the file attributes to allow the file to be executed. When... (2 Replies)
Discussion started by: simoncjones
2 Replies

8. Shell Programming and Scripting

A script doesnt work properly when crontab

Hi, I have a script which does a tar and sends it to another server as backup. Script is as below # Locations to be backed up. Seperate by space BACKUP_LOCATIONS=/repos/subversion BACKUP_BASE_FOLDER=/bakpool BACKUP_FILE_NAME_ROOT=svn-backup START_TIME_DISP=`date` START_TIME=`date... (11 Replies)
Discussion started by: digitalrg
11 Replies

9. Shell Programming and Scripting

cron does not execute script properly

I have a simple script that checks for certain printers and records them to a file. When I run the script manually at the command prompt, it works perfect, but when I run the script via cron, nothing happens. No errors reported, and no records are written out. I'm using Solaris 10. Below is the... (4 Replies)
Discussion started by: lmatlebyane
4 Replies

10. Shell Programming and Scripting

expr not outputting properly.. bsd sh script

When i run sh -x test.sh, expr outputs x=expr $x + 1 instead of doing the arithmetic.. been working on this overnight.. and its being a pain in the arse if you ask me.. :confused::confused: #!/bin/sh #script for downloading numerical filenames chap=1 p=1 count=0 x=1 while do if ... (2 Replies)
Discussion started by: aspect_p
2 Replies
Login or Register to Ask a Question