如何在linux中利用TFTP实现开机自动传输文件?

如何在linux中利用TFTP实现开机自动传输文件?

我正在尝试在启动时通过 tftp 获取文件。Tftp 服务器已在另一台机器上正确设置。我正在 shell 脚本中运行 tftp get,如下所示:

tftp 192.1x.x.110 << !
get file.txt
quit
!

当我执行此 shell 脚本时,它运行良好,并且我能够获取文件。我尝试将其作为 systemd 服务运行,但当它在启动时运行时,它只会给我一个空文件。

我的 systemd 服务如下所示:

[Unit]
Description=Grabbing TFTP file
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/home/debian/./test-tftp.sh
StandardOutput=null

[Install]
WantedBy=multi-user.target
Alias=tftp_file.service

当我自己启动 systemd 服务时,它也能正常工作,我得到了包含数据的文件,但只有在启动时它才会给我一个空文件。所以我想也许我没有在启动过程中的正确时间启动服务。

任何建议都将不胜感激。谢谢

相关内容