[SOLVED] TFTP in Debian 8.0

New to Debian (Or Linux in general)? Ask your questions here!

[SOLVED] TFTP in Debian 8.0

Postby tigger » 2017-08-30 05:41

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.
tigger
 
Posts: 7
Joined: 2017-08-30 05:26

Re: TFTP in Debian 8.0

Postby TonyT » 2017-08-30 10:04

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?
TonyT
 
Posts: 525
Joined: 2006-09-04 11:57

Re: TFTP in Debian 8.0

Postby tigger » 2017-08-30 16:41

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
tigger
 
Posts: 7
Joined: 2017-08-30 05:26

Re: TFTP in Debian 8.0

Postby bryanmc » 2017-08-31 01:40

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
bryanmc
 
Posts: 65
Joined: 2016-11-18 12:21

Re: TFTP in Debian 8.0

Postby tigger » 2017-08-31 04:24

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..
tigger
 
Posts: 7
Joined: 2017-08-30 05:26

Re: TFTP in Debian 8.0

Postby TonyT » 2017-08-31 10:00

Is "/remote/directory" world writable?
TonyT
 
Posts: 525
Joined: 2006-09-04 11:57

Re: TFTP in Debian 8.0

Postby bryanmc » 2017-08-31 11:36

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
bryanmc
 
Posts: 65
Joined: 2016-11-18 12:21

Re: TFTP in Debian 8.0

Postby tigger » 2017-08-31 14:14

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

Postby wizard10000 » 2017-08-31 14:51

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 -
we see things not as they are, but as we are.
-- anais nin
User avatar
wizard10000
 
Posts: 1205
Joined: 2011-05-09 20:02
Location: everywhere i go, there i am!

Re: TFTP in Debian 8.0

Postby tigger » 2017-08-31 15:21

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

Postby wizard10000 » 2017-08-31 19:27

tigger wrote: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.


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 -
we see things not as they are, but as we are.
-- anais nin
User avatar
wizard10000
 
Posts: 1205
Joined: 2011-05-09 20:02
Location: everywhere i go, there i am!

Re: TFTP in Debian 8.0

Postby tigger » 2017-09-01 03:46

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
tigger
 
Posts: 7
Joined: 2017-08-30 05:26

Re: TFTP in Debian 8.0

Postby reinob » 2017-09-01 12:42

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
reinob
 
Posts: 521
Joined: 2014-06-30 11:42

Re: [SOLVED] TFTP in Debian 8.0

Postby tigger » 2017-09-01 20:03

reinob wrote:https://stackoverflow.com/questions/4937792/using-variables-inside-a-bash-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!! :)
tigger
 
Posts: 7
Joined: 2017-08-30 05:26


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 9 guests

fashionable