Default42
Default42

Reputation: 93

How do I suppress echo of an SFTP get command in a bash script?

I have a bash script that logs into a remote server, pulls a file, then copies it on the local server to a subfolder. I want to run this as a scheduled cron job, so I don't want it printing any output. I managed to suppress the connection output by using the -q flag to the sftp command. But this script still prints:

sftp> get Export/data.xml

How do I go about suppressing this output? Below is my script.

sftp -q [email protected] <<EOF
get Export/data.xml
EOF
cp data.xml ./www/_resources/data

Upvotes: 3

Views: 1556

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202222

Prefix the command with @ as sftp man says:

Echo of the command may be suppressed by prefixing the command with a ‘@’ character.

@get Export/data.xml

Upvotes: 2

Related Questions