Prev: trying to parametrize find ...
Next: Automatically rename a downloaded file by curl to avoidfilename conflict.
From: Rikishi42 on 5 Feb 2010 14:05 On 2010-02-05, Hongyi Zhao <hongyi.zhao(a)gmail.com> wrote: > > > On Fri, 5 Feb 2010 01:24:10 +0100, Rikishi42 ><skunkworks(a)rikishi42.net> wrote: > >>Why bother ? Why not just put date and time in the file's name? >> >>get download date in a variable (not technically indispensable). >> OUTPUT_NAME=`date "+%Y%m%d_%H%M%S"` >> >>Then, eighter use: >> curl -o $OUTPUT_NAME >> >>or, if you can't specify a download name: >> curl -o >> mv myfile $OUTPUT_NAME > > If the system's time has happened to be changed by some virus, this > method maybe fail to generate the _unique_ OUTPUT_NAME. Sigh... I forgot I was in nitpicker's county, here. Yes, you're right. But don't you think the user has more urgent problems to deal with, then? Besides, there is a much bigger problem with the script as it is: DST. Once a year, the files will overwrite themselves for an hour. .... and even that is not an issue. Using UTC time, instead of local time, will solve that. -- Any time things appear to be going better, you have overlooked something.
From: Hongyi Zhao on 6 Feb 2010 23:58 On Thu, 4 Feb 2010 12:18:29 +0000 (UTC), Stephane CHAZELAS <stephane_chazelas(a)yahoo.fr> wrote: >url=http://www.google.com/ >file=myfile >( > set -C > ext= n=0 > until command exec 3> "$file$ext"; do > ext=.$((++n)) > done > exec curl "$url" >&3 >) The above code will give annoying output like this: line 15: myfile: cannot overwrite existing file. How can I suppress these output? Thanks in advance. -- ..: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
From: Hongyi Zhao on 7 Feb 2010 00:02 On Thu, 4 Feb 2010 12:18:29 +0000 (UTC), Stephane CHAZELAS <stephane_chazelas(a)yahoo.fr> wrote: > ext= n=0 Why this line must has a white space after *ext=*? Best regards. -- ..: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
From: Hongyi Zhao on 7 Feb 2010 07:28 On Sun, 7 Feb 2010 09:45:21 +0000 (UTC), Stephane CHAZELAS <stephane_chazelas(a)yahoo.fr> wrote: >until { command exec 3> "$file$ext"; } 2> /dev/null; do Good, thanks a lot. It does the trick. BTW, why cann't I use the following one: {until command exec 3> "$file$ext"; } 2> /dev/null; do Thanks again. -- ..: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
From: Hongyi Zhao on 7 Feb 2010 08:47 On Sun, 7 Feb 2010 13:27:26 +0000 (UTC), Stephane CHAZELAS <stephane_chazelas(a)yahoo.fr> wrote: >First, because, to be recognised as such the "{" keyword must be >followed by a blank, and then, the until is part of a "until, >do, done" sequence. {...} is group of commands, the >until,do,done would be unfinished in the {...}. > >You could do: > >{ > until ...; do > wget... > done >} 2> /dev/null > >or simply: > >until ...; do > wget... >done 2> /dev/null > >but then, the stderr of wget would also be redirected to >/dev/null, which is probably not what you want. Thanks a lot, I've got it. -- ..: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: trying to parametrize find ... Next: Automatically rename a downloaded file by curl to avoidfilename conflict. |