0

I am trying to create a script that I can use to transfer file via ftp access from a remote server to my own server(local server) using conjob.

The problem I am having a "bash scripts troubleshooting". Can some one please help me and look at the code and tell the problem and how to fix it.

I am not very good at coding please try to use simple english

This is the script iam trying to use:

#!/bin/sh
filename="/home/www////// " 
hostname=" FTP hostname "
username="FTP username "
password=" FTP password "
ftp -un $hostname <<EOF
quote USER $username
quote PASS $password
binary
put $filename
quit
EOF
Archemar
  • 1,687
  • 2
  • 16
  • 20
  • 2
    You have said you want to use `bash`, but your script header invokes Bourne shell: it should be `#!/bin/bash`, or `#!/bin/bash -x` if you want to log debug lines. – AFH Nov 15 '16 at 14:34
  • looks like you are sending file (from local to remote), what is exactly the error ? – Archemar Nov 15 '16 at 14:50
  • hey Archemar. Iam trying to receive from Remote to local. I tried to use #!/bin/bash but it did not work. I then contact my hosting support who told me that i had a bash scripts troubleshooting. I googled and found out that that i should try #!/bin/sh. what would you suggest if iam to recieve from remote to local. Thanks alot for your time. Regards remmy – Remmy Mayanja Nov 15 '16 at 15:43
  • This is not a script writing service. You have already been told how to debug it: insert, immediately after the shebang line, the line *set -x*. This produces debugging information step by step, it will help you find your error. It is more important to learn a general technique to debug something, than being handed the solution for a specific case. – MariusMatutiae Nov 15 '16 at 17:27
  • @RemmyMayanja you might consider putting all the ftp commands into a text file (say "commandfile") and running `ftp – uSlackr Nov 15 '16 at 17:37
  • @MariusMatutiae thanks for your explanation. I am stil new to writing scripts and coding in general, so I stil having alot to learn and I will try to learn more about general technique to debug. I will try what you suggested and se if it works – Remmy Mayanja Nov 15 '16 at 18:27
  • @uSlackr thanks for your suggestion, i will try it and see if I can solve the problem:-) – Remmy Mayanja Nov 15 '16 at 18:28
  • I've been trying to get this to work on a couple of FTP servers: on a local server on my intranet it works fine, but there is a problem with sending the password on a remote server, even when running interactively (FireFTP is OK) - rather odd. I've always used `~/.netrc` for automated transfers, as in [this answer](http://superuser.com/a/323268/327367), though you'll need to be sure of what account is being used for your `cron` job. Incidentally, on Ubuntu `ftp` doesn't understand the `-u` option. – AFH Nov 16 '16 at 18:29

0 Answers0