runner runner - 4 years ago 245
Bash Question

Create a bash file for transfer file through tftp

I want to create shell script to invoke tftp transfer of particular file to my local machine

this is the operation i want to do

get file1_in_remote location file2_in_local_machine

but I can't make it work, because when the 1st tftp command executes, control will got to tftp prompt. its just loook like this


And it wont accept the 2nd and 3rd commands i have given in the shell script.

but when I exit from the tftp prompt, bash prints an error message like

get: command not found
quit: command not found

So How can I get it done


tftp -c get MyFile1.txt MyFile2.txt
tftp -c get MyFile1.txt MyFile2.txt MyFile3.txt etc. etc.

these 2 commands not working with my ubuntu(14.0.4) system

Answer Source

I found the solution.

file1_in_remote location = "/tftpboot/file1.txt"
file2_in_local_machine = "/home/file2.txt"

tftp << !
#file names can be stored in varible
get ${file1_in_remote location} ${file2_in_local_machine}     

This worked for me

And There is one more solution

tftp << 'EOF'
#explictely specify the file names. varibales wont accept here.
get /tftpboot/file1.txt /home/file2.txt  

but in second solution you have to give the file location explicit. And in the 1st solution file name can be stored in variable and we can use that variable in the "get" command.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download