-3

I have a shell script that FTPs some non-sensitive data to a remote server. However, I would like to set the remote path rather than just use the remote FTP user's default path. I have searched for ages but can't find any way of doing this which seems crazy.

Here's a sample of a relevant part of my script;

#!/usr/bin/env bash

cd "$path" # local path
cp some.log "$stamp"_some.log
ftp -n -p $ftp_host <<END_SCRIPT
quote USER $ftp_user
quote PASS $ftp_pass
binary
put "$stamp"_some.log
quit
END_SCRIPT

Is there really no way to change the remote path to upload to?

Ally
  • 97
  • 2

1 Answers1

0

Just reading the ftp man page I see two ways:

cd /path/to/dir
put "$stamp"_some.log

Or:

put "$stamp"_some.log /path/to/dir/"$stamp"_some.log

Further, you can just skip the copy command and directly use:

put some.log /path/to/dir/"$stamp"_some.log
Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
  • I did check the man page and also before posting this question I tried cd /path before 'put' but it threw an error which seemed as though it was trying to change to a directory on the local machine. I also tried adding the remote path at the end of the put command but that failed. I didn't do what you did though which was also add the file name to the end. I will give your suggestions a go again now that I know they should work. I'll be back to accept your answer. – Ally Nov 08 '18 at 02:19