Find the answer to your Linux question:
Results 1 to 7 of 7
Hello people im needing a little help with a batch file. I have a sh file that downloads some files from an ftp site. wget -v -N --directory-prefix=/home/myname/mydownloaddirectory --random-wait --wait=120 ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    13

    Exclamation bash problem

    Hello people im needing a little help with a batch file.
    I have a sh file that downloads some files from an ftp site.

    wget -v -N --directory-prefix=/home/myname/mydownloaddirectory --random-wait --wait=120 --user=my username --password=my pass ftp://my ftp site/*.* &
    cp /home/myname/mydownloaddirectory /home/myname

    the problem that i have is that the copy command executes inmediately after the execution of the sh, it does not wait until i download all the files.
    I need it to wait until the files have been downloaded.
    Do you know how i can do this?. I can t use a wait statement because the sizes of the files may vary a lot.

    Thanks a lot

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    The '&' at the end of the wget line means "Background this process". This means that the process will be executed, and then the script will immediately move on to the next command.

    Remove that '&' and it should work.
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Just Joined!
    Join Date
    Jun 2007
    Posts
    13

    it works LIKE A CHARM!

    Thanks pal!
    Now the only problem i have is that the wget is not working in the background and i would like it to run in the background so it wont slow down all the other automatic tasks im running.
    Do you know any other way to do it?

  4. #4
    Linux Guru Juan Pablo's Avatar
    Join Date
    Mar 2006
    Location
    /home/south_america/ecuador/quito
    Posts
    2,064
    Use the -q option in wget
    Put your hand in an oven for a minute and it will be like an hour, sit beside a beautiful woman for an hour and it will be like a minute, that is relativity. --Albert Einstein
    Linux User #425940

    Don't PM me with questions, instead post in the forums

  5. #5
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    I'm not sure what you mean. When we say that a process is backgrounded, we mean that it doesn't connect to that particular shell instance, and therefore the shell is free to go on to other tasks. Further, the shell's input stream is still available for other programs to use.

    Juan Pablo's suggestion will prevent wget from printing anything out. If your concern is that wget will take up too much CPU power (though the concern probably isn't justified with wget), you can use the 'nice' command to change its priority. Run "man nice" to see how it works.
    DISTRO=Arch
    Registered Linux User #388732

  6. #6
    Just Joined!
    Join Date
    Jun 2007
    Posts
    13
    iĺl try to explain (sorry for my english im spanish).
    cabhan suggested to remove the & and he was right!. Now the shell executes the wget command and when its finished it copies the files from a folder to another.
    Now the problem i have is that when the shell runs the wget does not run on the background any more.
    Is background equal to use little cpu power?
    thanks a lot for the help.

  7. #7
    Linux Guru Juan Pablo's Avatar
    Join Date
    Mar 2006
    Location
    /home/south_america/ecuador/quito
    Posts
    2,064
    They dont make a great difference IMO, if you still want to be in the background, just use the -q option as I stated
    Put your hand in an oven for a minute and it will be like an hour, sit beside a beautiful woman for an hour and it will be like a minute, that is relativity. --Albert Einstein
    Linux User #425940

    Don't PM me with questions, instead post in the forums

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...