scp throws error


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers scp throws error
# 1  
Old 10-14-2011
scp throws error

My script is like

Code:
STAMP=$(perl -e '($ss, $mm, $hh, $DD, $MM, $YY) = localtime(time() - 100);
printf "%04d%02d%02d%02d%02d", $YY + 1900, $MM + 1, $DD, $hh, $mm')
touch $STAMP /sasdata/copydata/
find /sasdata/copydata -type f ! -newer /sasdata/copydata/ -print > output3.txt
awk '{print "scp  "$0" sasadmin@server2:/sasdata/copydata/a /sasdata/copydata/b "}' output3.txt | sh

output3.txt output is :

Code:
/sasdata/copydata/a/1.txt
/sasdata/copydata/b/2.txt
/sasdata/copydata/output3.txt

scp: /sasdata/copydata/a: not a regular file
cp: /sasdata/copydata/b/2.txt and /sasdata/copydata/b/2.txt are identical


I need to copy files to their respective directories but it gives error

---------- Post updated at 07:42 AM ---------- Previous update was at 02:47 AM ----------

can anybody tell me whats wrong am i doing

Last edited by pludi; 10-14-2011 at 07:06 AM..
# 2  
Old 10-14-2011
Try leaving off the "| sh" so you can see what it's actually feeding into sh.

Embedding your shell script deep inside awk like that doesn't strike me as a terrific idea. Makes your code hard to debug and hard to change.
# 3  
Old 10-14-2011
Try looking at rsync tool for the job with ssh encryption over network (optional)
# 4  
Old 10-14-2011
i dont have rsync pkg installed on my unix box

hi corona688 i can find modified files but can't transfer these files to respective directories by scp. please suggest siplest code to do that
# 5  
Old 10-14-2011
Simple and easy way:
Code:
find /sasdata/copydata -type f ! -newer /sasdata/copydata/ -exec scp '{}' username@host:/path/to/dest/ ';'

More efficient way:

Code:
IFS="
"

LOCALFILES="$(find /sasdata/copydata -type f ! -newer /sasdata/copydata/)"

scp ${LOCALFILES} username@host:/path/to/dest/

# 6  
Old 10-19-2011
can i copy files to same directry structure present on another server because while trying it shows error "Identical path"

Code:
IFS="
"
 
LOCALFILES="$(find /sasdata/copydata -type f ! -newer /sasdata/copydata/)"
 
scp ${LOCALFILES} username@host:/sasdata/copydata/a

Moderator's Comments:
Mod Comment Please use code tags


Code:
scp: /sasdata/copydata/a: not a regular file
cp: /sasdata/copydata/b/2.txt and /sasdata/copydata/b/2.txt are identical


Last edited by tushar_spatil; 10-19-2011 at 10:54 AM.. Reason: code tags, see PM
# 7  
Old 10-20-2011
What does echo $LOCALFILES do?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

Error during scp

Help needed for scp error. I tried to scp a file from a server to another with scp command, but I receive a error message "Non-Interactive Shell Disallowed!". I do not know what did I do wrong, please assist. I have done this before on other servers and have never faced this error. Both are... (2 Replies)
Discussion started by: kwliew999
2 Replies

2. Shell Programming and Scripting

Export Variable throws message

Friends, I'm trying to export a variable as follows. But getting error message "not a valid identifier". However the variable has exact value. # INSTSALL_PATH=/opt/tmp/Ora10.9/default # ORAHOME=/apps/opt/Oracle # export ${ORAHOME}=${INSTSALL_PATH} -bash: export:... (3 Replies)
Discussion started by: baluchen
3 Replies

3. Shell Programming and Scripting

Calling shell script within awk script throws error

I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
Discussion started by: Sudhakar333
10 Replies

4. Forum Support Area for Unregistered Users & Account Problems

Search throws a wobbly

Dear Administrator, Rule No.5 for unregistered users is impossible to comply with because Google search thinks that any Unix command that I search for is an attack from a virus and blocks the search. I managed to find this site from an external search, and it looks really useful. Do you... (2 Replies)
Discussion started by: Ken N
2 Replies

5. AIX

Copying to tape drive throws error

Hi All I am trying to copy files present in a partition (server 2) which is mounted to a different server (server 1) as tape drive is connected to it. I ran the below command to copy files within a partition: svr01:root:/sunfileserver> tar -cvf * a <foldername>/<filename>/<filename> a... (4 Replies)
Discussion started by: vathsan
4 Replies

6. Shell Programming and Scripting

Substr throws an ERROR. Any alternatives?

Can somebody please help me to remove the last character of a string.?? I have a string variable, in which I dynamically put values in a for loop.I want to remove the last character from the string. But, the problem is I will not know which character can come in the string (Its inside for... (3 Replies)
Discussion started by: naseert
3 Replies

7. UNIX for Dummies Questions & Answers

grep throws in dashes?

Hey guys, I'm trying to grep for two things out of a file and I got that working but why is it randomly throwing "--" in the output? Is there a simple way to get rid of them? It only seems to do it when the line above what im looking for has numbers in it. $ egrep -i -B 1... (3 Replies)
Discussion started by: kingdbag
3 Replies

8. Programming

fwrite throws segmentation fault

Code : function sSaveTFFile ....................... iRetCode = link (caCurrentFilename, caBackupFilename); if (iRetCode == -1) { ERR_MSG2(LOG_ALERT, "Can't move %s to %s", caCurrentFilename, caBackupFilename); return(FAILURE); } iRetCode = unlink... (6 Replies)
Discussion started by: fermisoft
6 Replies
Login or Register to Ask a Question