不进入tftp命令行执行tftp命令

run*_*ner 4 command-line bash tftp

我想在tftp不进入“tftp命令行”的情况下执行命令。

我尝试了以下命令:

tftp xx.xx.xx.xx -c put file1 file2
tftp xx.xx.xx.xx -m binary -c file1 file2
Run Code Online (Sandbox Code Playgroud)

但我得到了:

usage:tftp host-name [port]
tftp>
Run Code Online (Sandbox Code Playgroud)

在“用法:”消息之后,它进入tftp命令行。

我已经在打开详细选项的情况下尝试过。

我只想知道我给出的命令是否正常工作。“用法:”消息使它看起来好像不是tftp命令的正确用法。

此命令将从 Bash 文件中调用,该文件将从我正在处理的 CLI 应用程序中调用。

我已遵循此链接上的建议:https : //superuser.com/questions/581812/put-file-with-tftp-client-in-linux

hee*_*ayl 5

您可以使用 heredoc ( <<) 输入命令来执行一个又一个:

tftp host <<'EOF'
Enter
Commands
Here
EOF
Run Code Online (Sandbox Code Playgroud)

例子:

$ tftp localhost <<'EOF'
> ascii
> status
> quit
> EOF

tftp> tftp> Connected to localhost.
Mode: netascii Verbose: off Tracing: off
Rexmt-interval: 5 seconds, Max-timeout: 25 seconds
tftp> 

$ 
Run Code Online (Sandbox Code Playgroud)

如果你想要的tftp命令是

get file1 /home/foobar/test.txt
Run Code Online (Sandbox Code Playgroud)

你可以做:

$ tftp host <<'EOF'
> get file1 /home/foobar/test.txt
> quit
> EOF
Run Code Online (Sandbox Code Playgroud)