SCP Failing - In Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SCP Failing - In Script
# 1  
Old 11-18-2011
SCP Failing - In Script

I create a file that may contain several full path name files on a remote Linux that are to be copied. This file, called AWKOUTPUT is created from another script.
It contains:

Code:
X/picture1.png

The script is very simple
-------------------------------------------
Code:
REMOTEDIR="/var/CC/Stuff"
for i in `cat AWKOUTPUT`
 do
  echo $i
 scp user1@host:$REMOTEDIR/$i ./
done

--------------------------------------------
The scp fails indicating the file doesn't exist.
If I run scp manually it works fine, so the file does exist.
If I change the script to

--------------------------------------------

Code:
FILE="/var/CC/Stuff/X/picture1.png"
scp user1@host:$FILE ./

----------------------------------------------

it works fine.

If I add the -v option to scp the debug output cmd sent looks fine

Code:
debug1: Sending command: scp -v -f /var/CC/Stuff/X/Picture1.png
Sending file modes: C0644 739478 Picture1.png

Any suggestions ?

Last edited by pludi; 11-18-2011 at 06:28 AM..
# 2  
Old 11-18-2011
Try this and see what it returns:
Code:
REMOTEDIR="/var/CC/Stuff"
while read fname
do
	remoteFile="${REMOTEDIR}/${fname}"
	
	echo "remoteFile: [${remoteFile}]"
	
	echo "ls -l ${remoteFile}" | ssh -C -T -l <user> <host>
	scp -vvv <user>@<host>:${remoteFile} ./
done < AWKOUTPUT

Also, you should check this link: Useless Use of Cat Award

I hope it helps!
# 3  
Old 11-18-2011
I tried your suggestion put still get the error on the scp that the file is unknown or doesn't exist.
It seems that taking some type of redirection to create the remote filename variable causes the problem.
# 4  
Old 11-21-2011
Can you post the output of the script (-vvv, ssh debug)? Also, what is the source OS?

I can't understand why it is not working, I use it for a long time without problems!
# 5  
Old 11-21-2011
Source system is Max OSX 10.6.8
I will try to post the output later.

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Crontab script failing

Hello, A crontab script is failiing everyday but when we execute manually it runs fine Below is the script scheduled: 00 23 * * * sh /db2backup/scripts/db2_hot_backup.ksh TRAVFF > /dev/null 2>&1 Error: cat TRAVFF_online_04022014_2300.log Started : Wed Apr 2 23:00:00 EDT 2014... (2 Replies)
Discussion started by: Vishal_dba
2 Replies

2. UNIX for Dummies Questions & Answers

Script test failing

Testing some old script developed by different user. #!/usr/bin/sh case "$0" in */*) cmd="$0";; *) cmd=`which "$0"`;; esac dir=`dirname "$cmd"` node="$dir/." echo $node below two simple tests are failing, I am not seeing any Control+M characters in the script file and I am not able... (4 Replies)
Discussion started by: srimitta
4 Replies

3. Shell Programming and Scripting

Script running in parallel failing!

Hi, I have a single script that was running fine in parallel on Linux 2.6.9-89 now it has been upgraded to Linux 2.6.18-308.24.1.el5 and the script has started to fail unpredictably. Is this an upgrade issue? As the script runs fine for some parallel threads while fails for others. Please... (4 Replies)
Discussion started by: Panna
4 Replies

4. Shell Programming and Scripting

Script running for one iteration and failing the second one

Hi, I am using Tclexpect to automation testing on switches and using regexp and the buffer outputs the program is running well for one iteration and failing the second one... can anyone please guide me what is the mistake i am making? Thanks Here is the small version of the program, while... (2 Replies)
Discussion started by: roh_20022002
2 Replies

5. Solaris

oracle cron script failing.

I have this oracle script which my dba is trying to run as a cron job that fails. attached is the script. It seems to run when executed by itself but just not when scheduled. (3 Replies)
Discussion started by: Kjons76
3 Replies

6. Shell Programming and Scripting

Expect script help needed- script failing if router unavailable

Hey all. Sometimes I'm tasked to change some router configs for the entire network (over 3,000 Cisco routers). Most of the time its a global config parameter so its done with a loop and an IP list as its the same configuration change for all routers. This is working OK. However, sometimes an... (3 Replies)
Discussion started by: mrkz1974
3 Replies

7. UNIX for Advanced & Expert Users

Serializing script Failing for more commands

I have a reqirement to serialise various rsh scripts that hit my server from an external scheduler. No matter how many scripts come via rsh, only one should execute at a time and others should wait. I have made the scheduler make a request to my shell script with the command to be run as a... (4 Replies)
Discussion started by: nkamatam
4 Replies

8. UNIX for Dummies Questions & Answers

failing a unix script

i am basically DWH professional. I want to write a script such that whenver the file size is greather than 0 the script fails plz help me in this (1 Reply)
Discussion started by: er_zeeshan05
1 Replies

9. Shell Programming and Scripting

IF condition failing in a SSH script

Hi, I'm ssh-in to a remote machine (ubuntu) and trying to execute a little script in there.The script looks like this: ssh user@ubuntu <<EOF cd ~/test ls -l echo "Continue counting files starting with a`s ?" read answer if then ls -l a* else exit fi EOF Now everything works... (9 Replies)
Discussion started by: rubionis
9 Replies

10. UNIX for Advanced & Expert Users

UNIX script failing ....

Hi folks, I have written down a UNIX script which actually FTP the file to other server. What is happening now , this script is not working only for 1 server , as it is working for 32 different FTP server . In this particular server , we are getting message “FTp:550 access denied”... (1 Reply)
Discussion started by: khan1978
1 Replies
Login or Register to Ask a Question