使用heredoc重定向命令输出

时间:2012-06-05 09:12:09

标签: bash heredoc zenity

我有这样的命令:

sftp user@host <<EOF
put file.txt
exit
EOF

现在我想把它的输出传递给zenity --progress,但我找不到放置它的地方。

# 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 个答案:

答案 0 :(得分:10)

这应该可以解决问题:

sftp user@host <<EOF | zenity --progress
...
EOF