Re: Is there a better way

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



MARG said:
> Hi,
>
> I'm doing this script (after my signature) that starts by downloading
> files from the web.
> It checks for each file if the download was successful.
>
> Is theres a fancier way to do the test, instead of repeating
> -----------------------------------
> code=$?
> if [ $code != 0 ]
>  then
>   echo "Couldn't retrieve file :("
>   exit 1
> fi
> -----------------------------------
>
> for each file ?

How about putting your links in a nice file

for link in `cat mylinksfile`; do

wget $link
blah blah blah
done

using && in place of ; might help too, as the next command (after &&) only
gets ran if the first was error free.

also if [!$?] should work in this case as well (test it though)

> Any help would be apreciated.

You need a book on UNIX Shell scripting.  There are loads of free stuff
out there.  :)

--
Scott

-
: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux