15

I have a legacy script which I am not able to understand.

The script is to transfer 4 files (2 ebcdic format files and 2 pdf files) in unix to mainframes through ftp.

ebcdic format file 1 is abc.xyz
ebcdic format file 2 is pqr.xyz
pdf file 1 is abc.pdf
pdf file 2 is pqr.pdf
mainframe file name is AM2P.BJCUN.SALCHG

The syntax of the command in the script is as below:

quote site recfm=fb
put /myfiles/abc.xyz AM2P.BJCUN.SALCHG
append /myfiles/abc.pdf AM2P.BJCUN.SALCHG
append /myfiles/pqr.xyz AM2P.BJCUN.SALCHG
append /myfiles/pqr.pdf AM2P.BJCUN.SALCHG

I want to achieve the same thing through SCP.

Could someone please tell what is the equivalent of put and append command of ftp in scp ??

Vicky
  • 16,679
  • 54
  • 139
  • 232

2 Answers2

30

Put is just the normal scp

scp /path/to/source user@host:/path/to/target

Append only works with a little hack (and not with scp directly)

cat source | ssh user@host "cat >> /path/to/target"
moodywoody
  • 2,149
  • 1
  • 17
  • 21
  • You will also have to read up on how to specify a data set name using the path name syntax. – zarchasmpgmr Apr 03 '12 at 05:06
  • If you need to *resume* the appending (after a network disconnection for example), you may check how many *remote* bytes were already transfered (current remote file size) and then check this answer for `cat`ing after the desired number of skipped byes: https://unix.stackexchange.com/questions/52820/skip-first-3-bytes-of-a-file – Gabriel Nov 15 '17 at 12:04
0

scp can not append (ssh can, but it is not always an option). You can copy remote file, append it locally and then put it back.

user3132194
  • 2,381
  • 23
  • 17