Reputation: 1
I am trying to make a bash script to send a file. When running this in the terminal I get the error:
line 4: warning: here-document at line 2 delimited by end-of-file (wanted `EOF
Here is the script:
#!/bin/bash
sshpass -p 'password' scp /dir/sub/sub/sub/sub/file.csv [email protected]:/ <<-EOF
quit
EOF
It will send the file but when I have tried to run the script with crontab it will not run. What do I need to change? Also I am only able to use a password and not keys.
Upvotes: 0
Views: 187
Reputation: 4865
I tested the following code to work:
cron-job--scp-files-locally.sh
#!/bin/bash
# create an ind file with current minute timestamp
touch $(date +%Y-%m-%d_%H%M).ind
# scp all ind files to /tmp with user metoo
/usr/bin/sshpass -p 'greatPassword' /usr/bin/scp *.ind metoo@localhost:/tmp
# remove all ind files
rm -f *.ind
* * * * * /home/greatuser/cron-job--scp-files-locally.sh
ls -1 /tmp/*ind
/tmp/2023-12-11_1619.ind
/tmp/2023-12-11_1620.ind
/tmp/2023-12-11_1621.ind
#!/bin/bash
/usr/bin/sshpass -p 'greatPassword' /usr/bin/scp /dir/sub/sub/sub/sub/file.csv [email protected]:/
Upvotes: 0