Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED] TFTP in Debian 8.0

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
tigger
Posts: 7
Joined: 2017-08-30 05:26

[SOLVED] TFTP in Debian 8.0

#1 Post by tigger »

Hello,

I'm a beginner to Debian Linux and I have a question regarding TFTP.
I'm trying to run it in script.
#!/bin/bash
FILE="/home/eclipse/test.txt"
tftp 192.168.0.50 << '!'
put ${FILE} /remote/directory
quit
!
exit 0

When I run it:
tftp: ${FILE}: No such file or directory

I've done many researches, but couldn't solve it.
Please help!
Last edited by tigger on 2017-09-01 20:01, edited 2 times in total.

TonyT
Posts: 575
Joined: 2006-09-04 11:57

Re: TFTP in Debian 8.0

#2 Post by TonyT »

When I run it:
tftp: ${FILE}: No such file or directory
Looks like the path to the file is not correct, where is the file?
${FILE} = what exact path?

tigger
Posts: 7
Joined: 2017-08-30 05:26

Re: TFTP in Debian 8.0

#3 Post by tigger »

Hello TonyT,

It's located in /home/eclipse/
It works when I manually typed in.
tftp 192.168.0.50 << '!'
put /home/eclipse/test.txt /home/eclipse/test.txt /remote/directory/
quit
!

Terminal respond:
Sent 5627 bytes in 0.0 seconds
Sent 5627 bytes in 0.0 seconds

bryanmc
Posts: 122
Joined: 2016-11-18 12:21
Has thanked: 2 times

Re: TFTP in Debian 8.0

#4 Post by bryanmc »

Disclaimer: I'm horrible at bash scripting... That said, I think it should look like this....

Code: Select all

#!/bin/bash
export FILE=/home/eclipse/test.txt
tftp 192.168.0.50 << '!'
put $FILE /remote/directory
quit
!
exit 0

tigger
Posts: 7
Joined: 2017-08-30 05:26

Re: TFTP in Debian 8.0

#5 Post by tigger »

Hello Bryanmc,

I've done that but same result...
tftp: $FILE: No such file or directory

I've tried others:
With the quote -> export FILE="/home/eclipse/test.txt" or, FILE="/home/eclipse/test.txt"
Without the quote -> export FILE=/home/eclipse/test.txt or, FILE=/home/eclipse/test.txt
With braces {}, parentheses (), quotation "" around FILE
However, no uses..

TonyT
Posts: 575
Joined: 2006-09-04 11:57

Re: TFTP in Debian 8.0

#6 Post by TonyT »

Is "/remote/directory" world writable?

bryanmc
Posts: 122
Joined: 2016-11-18 12:21
Has thanked: 2 times

Re: TFTP in Debian 8.0

#7 Post by bryanmc »

tigger wrote:Hello Bryanmc,

I've done that but same result...
tftp: $FILE: No such file or directory
But did you export the variable for FILE?

export FILE=/home/eclipse/test.txt

tigger
Posts: 7
Joined: 2017-08-30 05:26

Re: TFTP in Debian 8.0

#8 Post by tigger »

Is "/remote/directory" world writable?
Yes, it's writable.
But did you export the variable for FILE?

export FILE=/home/eclipse/test.txt
Yes, I've done that.

tigger
Posts: 7
Joined: 2017-08-30 05:26

Re: TFTP in Debian 8.0

#9 Post by tigger »

wizard10000 wrote:Try this -

Code: Select all

#!/bin/bash
FILE = "/home/eclipse/test.txt"
tftp 192.168.0.50 -c put ${FILE} /remote/directory
exit 0
Part of the problem you appear to have is that some versions of FTP (and TFTP) don't invoke a shell so you can't pass shell variables to them.

Good luck -
wizard10000, thanks for your advice.
I'm currently using tftp-hpa 5.2, with remap, with tcpwrappers.

I got following respond now:
usage: tftp host-name [port]
tftp>

I had to enter "quit" to exit from there.

tigger
Posts: 7
Joined: 2017-08-30 05:26

Re: TFTP in Debian 8.0

#10 Post by tigger »

wizard10000 wrote:Check the man page for your tftp client and see if it supports the -c switch. It's possible you're not able to pass shell variables to your tftp client - if that's the case you may not be able to get there from here :(

edit: I just installed Debian's tftp client and read its man page - it doesn't support -c as a command line argument. Since a tftp session isn't a shell you can't pass shell environment variables to it; you have to assign them client-side and Debian's tftp client doesn't support that.

Wish I had better news -
Okay, thanks for letting me know..
BR

reinob
Posts: 1196
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: TFTP in Debian 8.0

#11 Post by reinob »

tigger wrote:Hello,

I'm a beginner to Debian Linux and I have a question regarding TFTP.
I'm trying to run it in script.
#!/bin/bash
FILE="/home/eclipse/test.txt"
tftp 192.168.0.50 << '!'
put ${FILE} /remote/directory
quit
!
exit 0

When I run it:
tftp: ${FILE}: No such file or directory

I've done many researches, but couldn't solve it.
Please help!
https://stackoverflow.com/questions/493 ... sh-heredoc
Don't use '!' as delimiter.
Instead, do like:

Code: Select all

tftp 192.168.0.50 <<EOF
put ${FILE} /remote/directory
quit
EOF

tigger
Posts: 7
Joined: 2017-08-30 05:26

Re: [SOLVED] TFTP in Debian 8.0

#12 Post by tigger »

reinob wrote:https://stackoverflow.com/questions/493 ... sh-heredoc
Don't use '!' as delimiter.
Instead, do like:

Code: Select all

tftp 192.168.0.50 <<EOF
put ${FILE} /remote/directory
quit
EOF
It works! Thank you!! :)

Post Reply