Copying files to remote server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copying files to remote server
# 1  
Old 02-19-2018
Copying files to remote server

I am trying to copy code to remote server, doing something like this

However it is copying one file and than the script exits

Code:
i=0; j=0
while read fn; do    

  dir=${fn%/*}  # Gets directory path
  fnm=${fn##*/} # Gets filename excl. path

  rgx_nwk="s/${nwk}/${nwk}.sac/g"
  odir_nwk=`echo "$dir" | sed -e $rgx_nwk`
  ofl_nwk="${odir_nwk}/${fnm}"

  smru_web="smru-web@albert.grid.um.edu.mt"
  smru_ictja="/home/smru-web/cdi/resip/ictja"

  rgx="s#/media/hagbard/DS521260/##g"
  odir_smru=`echo "$dir" | sed -e $rgx`
  odir_smru="${smru_ictja}/${odir_smru}"

  ssh ${smru_web} "mkdir -p $odir_smru"
  scp $fn ${smru_web}:${odir_smru}/ 

done < /tmp/wrk
printf "\n"

# 2  
Old 02-19-2018
What does /tmp/wrk look like? Is it a normal UNIX file for example, not some windows formatted file?

Please show the output of: file /tmp/wrk

Plus, this -- scp $fn ${smru_web}:${odir_smru}/
$fn is a directory not a file name - is that what you intend - you get the same named directory on the remote. In the output directory

Last edited by jim mcnamara; 02-19-2018 at 11:22 AM..
# 3  
Old 02-19-2018
$fn is the file I want to transfer


Code:
file /tmp/wrk
/tmp/wrk: ASCII text

scp /media/hagbard/DS521260/ingv/iv/hpac/hhz.d/iv.hpac..hhz.d.2016.001 smru-web@albert.grid.um.edu.mt:/home/smru-web/cdi/resip/ictja/ingv/iv/hpac/hhz.d/

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Shell Programming and Scripting

Copying the files to Windows server from UNIX server

Hi Team, I had a requirement to write a shell script which automatically transfer the files from unix server to windows server. I can able to unix to unix using Scp command. I am not sure how to do unix to windows. I am very new on this concept. Could you please help me or guide in... (4 Replies)
Discussion started by: gvkumar25
4 Replies

3. UNIX for Dummies Questions & Answers

Help with Copying files between two remote servers

Hi All, Please help me for a shell. I am a New to unix I am trying to DB dump file from one server and copying it to another server. From My Local ServerA connecting to remote ServerB using ssh and taking dump of a instance. That Dump file i need to copy to ServerC. I am able to connect... (6 Replies)
Discussion started by: maddyd2k
6 Replies

4. UNIX for Dummies Questions & Answers

Copying files to a remote NFS filesystem

Hi guys Maybe a stupid question.. IS possible, in unix, to copy files to a remote NFS shared filesystem without mounting it? Just like windows does: copy * \\folderA\folderB Thanks.. (4 Replies)
Discussion started by: iga3725
4 Replies

5. UNIX for Dummies Questions & Answers

Copying files from different server

Is there any option to copy files from a different server other than using an SCP command??? thanks,:b: Arun manas (2 Replies)
Discussion started by: arunmanas
2 Replies

6. Shell Programming and Scripting

Copying files from one server to other.

Any one advice here- need to copy some files from one server to other server thru shell programming. (8 Replies)
Discussion started by: samkhu
8 Replies

7. Shell Programming and Scripting

copying files from remote computer

hi, i want to copy files from a remote computer in a network to a specific directory on my PC. ( script ) Forexample , IP of the remote PC is 172.16.5.24 login:aaaa Passw:123 /folder1/file1.txt to my pc folder /fd/awa.txt kinldy help Thanks (2 Replies)
Discussion started by: krabu
2 Replies

8. UNIX for Dummies Questions & Answers

Copying files from a remote server to local system with cygwin

Hi. I'm sorry if I get on people's nerves asking this, but I don't really understand how to do this and unfortunately don't have the time to work through it step by step in books, etc. At University, we have a unix server that hosts our files. we each have a login and password to access it. I... (3 Replies)
Discussion started by: patwa
3 Replies

9. UNIX for Dummies Questions & Answers

Copying files from laptop to remote server using SSH

Hello, I'm sorry if this sounds like a very simple question, but I'm having some difficulty with it being a complete newbie to UNIx. I use Windows, and always have, but need some UNIX access for work, picking up files from our group space, etc. Basically, I'm using Cygwin and can SSH into the... (3 Replies)
Discussion started by: patwa
3 Replies

10. AIX

copying files to a remote aix server using tar!

Hi, I am using AIX 5.2, and I want to copy some files from one server to a remote server using tar command. Can anybody tell me exact command? Thanks. Aqeel (2 Replies)
Discussion started by: system-admin
2 Replies
Login or Register to Ask a Question