问题
I have a command like this:
sftp user@host <<EOF
put file.txt
exit
EOF
Now I'd like to pipe the output of that to zenity --progress
, but I can't find a place to put it.
# SFTP doesn't work anymore
sftp user@host | zenity --progress <<EOF
put file.txt
exit
EOF
# Invalid syntax, no end of heredoc
sftp user@host <<EOF
put file.txt
exit
EOF | zenity --progress
# Not picked as part of the command
sftp user@host <<EOF
put file.txt
exit
EOF
| zenity --progress
# Does not help
sftp user@host | zenity --progress <<EOF
put file.txt
exit
EOF\
| zenity --progress
回答1:
This should do the trick:
sftp user@host <<EOF | zenity --progress
...
EOF
来源:https://stackoverflow.com/questions/10894554/redirect-output-of-command-with-heredoc