Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to download a file Ttytter using wget and run it in the terminal. I can do that by gnome-terminal --tab -e 'wget http://www.floodgap.com/software/ttytter/dist2/2.0.02.txt -O /tmp/ttytter.pl && perl /tmp/ttytter.pl -hold' but if my connection is not established then how do I make wget to wait till connection established and then download the file.

share|improve this question
    
Have you tried the new suggestions in my answer? It should be what you want! –  user76204 Jul 27 '12 at 11:03

1 Answer 1

I think the best thing to do would be to write a script which pinged the url until it was available and then launched your command when the link came up. The script could use a while loop for the ping command, and when the url was available, the loop could be broken and your command would be run. There are some good scripts here, which could be adapted and which explain the process in detail.

Good news, I have just tested the script below by going off-line and then coming back on again and it gives me a copy of ttytter.pl in my tmp folder and launches the program!

#!/bin/bash
while true; do ping -c1 www.floodgap.com > /dev/null && break; done
wget http://www.floodgap.com/software/ttytter/dist2/2.0.02.txt -O /tmp/ttytter.pl && perl /tmp/ttytter.pl -hold done

Once you have saved this script and made it executable, you can simply add it as a startup item using the graphical startup manager (but remember to check the option to run as an application in the terminal). Alternatively, put this command in the appropriate area of the box provided by the startup manager: gnome-terminal -e /location/of/above/script

If you have any problems with placing the script in startup, you can create a launcher for it, select to run it as an application in the terminal, then pin it to your panel or desktop. Then click the launcher after you login and it will wait until the connection is established and will then download and launch ttytter.

share|improve this answer
    
I tried wget --tries=50 http://www.floodgap.com/software/ttytter/dist2/2.0.02.txt -O /tmp/ttytter.pl with error --2012-07-25 01:26:29-- floodgap.com/software/ttytter/dist2/2.0.02.txt Resolving www.floodgap.com (www.floodgap.com)... failed: Name or service not known. wget: unable to resolve host address `www.floodgap.com' –  Ankit Haldar Jul 24 '12 at 20:01
1  
Yes you're right; I got the same error. I think writing a script probably would be the best thing as it might not be possible to do what you want with wget. –  user76204 Jul 24 '12 at 20:20
    
can you guide me? and also it should start up at boot. –  Ankit Haldar Jul 24 '12 at 20:23
1  
yes-take a look at my edited answer; it now contains a script and some instructions. –  user76204 Jul 24 '12 at 22:30
    
I copied ttytter to /usr/bin making it executable. pinned a starter to startup-applications. –  Ankit Haldar Aug 27 '12 at 17:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.