Another oddity from Gene
Greetings; I made a movie out of a machining operation which put nearly 18GB in .avi files in my /usr/movies DLE. So this mornings report for the 2nd time, notes its too big, and only wrote a PARTIAL, then ran out of space, and I had added another 20GB to the size of the vtape yesterday. I'll add another 10GB today. But, I thought I would clean out the holding disk by doing a flush by hand, and found a piece of my script that has worked numerous times before, is now broken. The command line issued from the /GenesAmandaHelper-0.6 directorry, as the use amanda is: ./flush.sh Daily The 6 line snippet of backup.sh, which flush.sh is a softlink to is: # or are we running as flush.sh if [ $0 == ./flush.sh ]|| [ $0 == ${MYDIR}/flush.sh ]||[ $0 == flush.sh ]; then # we don't want amflush to disconnect or ask questions if [`/bin/ls /dumps`]; then line 173 echo Backup script running amflush -bf $CONFIGNAME $LOG = The if statement probably needs help but all its looking for is a non-null response, or at least that's the theory when I wrote it and its worked since years now. But, now I get this return on the command line: = ./flush.sh: line 173: [20091019011512]: command not found = and the echo line above never makes it to the log, here it is: = ./flush.sh started on 19/10/09 07:10:37 with arg Daily CONFIGNAME = Daily First put the tapelist in order with a run of amcheck running /usr/local/sbin/amcheck Daily Amanda Tape Server Host Check - Holding disk /dumps: 308895744 kB disk space available, using 308383744 kB stage 1: search for oldest reusable volume oldest reusable volume is 'Dailys-3' changer is not fast-searchable; skipping to stage 2 stage 2: scan for any reusable volume trying slot 3 Will write to volume 'Dailys-3' in slot 3. NOTE: skipping tape-writable test Server check took 1.014 seconds Amanda Backup Client Hosts Check Client check: 2 hosts checked in 2.460 seconds. 0 problems found. (brought to you by Amanda 2.6.2alpha) Back in ./flush.sh - and the lists should be sane line 72 ./flush.sh tapenum from /usr/local/etc/amanda/Daily/chg-disk-slot is now=3 TAPECYCLE=30 RUNTAPES=1 This script is being run as ./flush.sh No dumps left in holding disk area, ./flush.sh has been skipped ---is the else clause of that 'if' in line 173 flush-indices-configs is done and completed successfully. --'echo' line is trash, removed now amcheckdump run is disabled by gene.conf config. ==end of log= But: [ama...@coyote Daily]$ ls /dumps 20091019011512 [ama...@coyote Daily]$ du /dumps 17856304/dumps/20091019011512 17856312/dumps [ama...@coyote Daily]$ ls -lR /dumps /dumps: total 4 drwx-- 2 amanda amanda 4096 2009-10-19 02:35 20091019011512 /dumps/20091019011512: total 17856300 -rw--- 1 amanda amanda 291857 2009-10-19 02:34 coyote._opt.1 -rw--- 1 amanda amanda 43008 2009-10-19 02:35 coyote._sbin.1 -rw--- 1 amanda amanda 73728 2009-10-19 02:27 coyote._usr_dlds_misc.1 -rw--- 1 amanda amanda 43008 2009-10-19 02:34 coyote._usr_dlds_rpms.1 -rw--- 1 amanda amanda 43008 2009-10-19 02:34 coyote._usr_dlds_tgzs.1 -rw--- 1 amanda amanda 2097152000 2009-10-19 02:17 coyote._usr_movies.1 -rw--- 1 amanda amanda 2097152000 2009-10-19 02:19 coyote._usr_movies.1.1 -rw--- 1 amanda amanda 2097152000 2009-10-19 02:20 coyote._usr_movies.1.2 -rw--- 1 amanda amanda 2097152000 2009-10-19 02:22 coyote._usr_movies.1.3 -rw--- 1 amanda amanda 2097152000 2009-10-19 02:23 coyote._usr_movies.1.4 -rw--- 1 amanda amanda 2097152000 2009-10-19 02:24 coyote._usr_movies.1.5 -rw--- 1 amanda amanda 2097152000 2009-10-19 02:25 coyote._usr_movies.1.6 -rw--- 1 amanda amanda 2097152000 2009-10-19 02:26 coyote._usr_movies.1.7 -rw--- 1 amanda amanda 1485770752 2009-10-19 02:27 coyote._usr_movies.1.8 -rw--- 1 amanda amanda 43008 2009-10-19 02:34 coyote._usr_music.1 -rw--- 1 amanda amanda3428215 2009-10-19 02:33 coyote._usr_src.1 Can somebody teach me a better 'if' in line 173? Thanks. PS: I would still like to be able to turn the amcheckdump option back on, but until it loses the required cli confirmation, that's DIW. -- Cheers, Gene There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) The NRA is offering FREE Associate memberships to anyone who wants them. https://www.nrahq.org/nrabonus/accept-membership.asp Never argue with a fool -- people might not be able to tell the difference.
Re: Another oddity from Gene
On Monday 19 October 2009, Dustin J. Mitchell wrote: On Mon, Oct 19, 2009 at 8:05 AM, Gene Heskett gene.hesk...@verizon.net wrote: if [`/bin/ls /dumps`]; then line 173 This can be a bit tricky in portable shell, but maybe this is closer to what you want: if [ `/bin/ls /dumps` != '' ] Dustin I'll try that, but IIRC if the dir is empty, ls still returns a linefeed. brb. Nope, tried with !='' and !='\n', with almost the same result, the diff being that now the error message on the console is minus the ending ] now. ./flush.sh: line 173: [20091019011512: command not found I fail to see why bash is looking for that ls return as a command to be executed, almost like bash is busted, and its been ages since bash was updated. This script has worked many times since the last time I saw a bash update go by. its enough to make a fellow wish it was beer-thirty and I haven't even finished my first cup of tea! -- Cheers, Gene There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) The NRA is offering FREE Associate memberships to anyone who wants them. https://www.nrahq.org/nrabonus/accept-membership.asp DON'T go!! I'm not HOWARD COSELL!! I know POLISH JOKES ... WAIT!! Don't go!! I AM Howard Cosell! ... And I DON'T know Polish jokes!!
Re: Another oddity from Gene
On 2009-10-19 16:34, Gene Heskett wrote: On Monday 19 October 2009, Dustin J. Mitchell wrote: On Mon, Oct 19, 2009 at 8:05 AM, Gene Heskett gene.hesk...@verizon.net wrote: if [`/bin/ls /dumps`]; then line 173 This can be a bit tricky in portable shell, but maybe this is closer to what you want: if [ `/bin/ls /dumps` != '' ] Dustin I'll try that, but IIRC if the dir is empty, ls still returns a linefeed. brb. Nope, tried with !='' and !='\n', with almost the same result, the diff being that now the error message on the console is minus the ending ] now. ./flush.sh: line 173: [20091019011512: command not found In portable shell, there must be space before and after the '[' and ']' as well as before and after the comparison operator. I fail to see why bash is looking for that ls return as a command to be executed, almost like bash is busted, and its been ages since bash was updated. This script has worked many times since the last time I saw a bash update go by. its enough to make a fellow wish it was beer-thirty and I haven't even finished my first cup of tea! -- Paul Bijnens, Xplanation Technology ServicesTel +32 16 397.525 Interleuvenlaan 86, B-3001 Leuven, BELGIUM Fax +32 16 397.552 *** * I think I've got the hang of it now: exit, ^D, ^C, ^\, ^Z, ^Q, ^^, * * quit, ZZ, :q, :q!, M-Z, ^X^C, logoff, logout, close, bye, /bye, ~., * * stop, end, ^]c, +++ ATH, disconnect, halt, abort, hangup, KJOB, * * ^X^X, :D::D, kill -9 1, kill -1 $$, shutdown, init 0, Alt-F4, * * Alt-f-e, Ctrl-Alt-Del, Alt-SysRq-reisub, Stop-A, AltGr-NumLock, ... * * ... Are you sure? ... YES ... Phew ... I'm out * ***
Re: Another oddity from Gene
On Mon, Oct 19, 2009 at 10:34 AM, Gene Heskett gene.hesk...@verizon.net wrote: I'll try that, but IIRC if the dir is empty, ls still returns a linefeed. brb. Nope, tried with !='' and !='\n', with almost the same result, the diff being that now the error message on the console is minus the ending ] now. ./flush.sh: line 173: [20091019011512: command not found The whitespace is significant in the command I showed: if [ `/bin/ls /dumps` != ] btw, the shell strips leading and trailing whitespace, so don't worry about the newline. Dustin -- Open Source Storage Engineer http://www.zmanda.com
Re: Another oddity from Gene
On Monday 19 October 2009, Paul Bijnens wrote: On 2009-10-19 16:34, Gene Heskett wrote: On Monday 19 October 2009, Dustin J. Mitchell wrote: On Mon, Oct 19, 2009 at 8:05 AM, Gene Heskett gene.hesk...@verizon.net wrote: if [`/bin/ls /dumps`]; then line 173 This can be a bit tricky in portable shell, but maybe this is closer to what you want: if [ `/bin/ls /dumps` != '' ] Dustin I'll try that, but IIRC if the dir is empty, ls still returns a linefeed. brb. Nope, tried with !='' and !='\n', with almost the same result, the diff being that now the error message on the console is minus the ending ] now. ./flush.sh: line 173: [20091019011512: command not found In portable shell, there must be space before and after the '[' and ']' as well as before and after the comparison operator. Bingo! Its running normally with the original syntax. And I would be willing to bet that many of the conditionals in that script which have the same basic syntax had to be surrounded by [[ and ]] to make them work right, right? Same reason. And I see an error message in the log that isn't, time to print that script and recheck the conditionals. Thank you Paul. -- Cheers, Gene There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) The NRA is offering FREE Associate memberships to anyone who wants them. https://www.nrahq.org/nrabonus/accept-membership.asp Your modem doesn't speak English.
Re: Another oddity from Gene
On Mon, Oct 19, 2009 at 8:05 AM, Gene Heskett gene.hesk...@verizon.net wrote: if [`/bin/ls /dumps`]; then line 173 This can be a bit tricky in portable shell, but maybe this is closer to what you want: if [ `/bin/ls /dumps` != '' ] Dustin -- Open Source Storage Engineer http://www.zmanda.com
Re: Another oddity from Gene
On Monday 19 October 2009, Dustin J. Mitchell wrote: On Mon, Oct 19, 2009 at 10:34 AM, Gene Heskett gene.hesk...@verizon.net wrote: I'll try that, but IIRC if the dir is empty, ls still returns a linefeed. brb. Nope, tried with !='' and !='\n', with almost the same result, the diff being that now the error message on the console is minus the ending ] now. ./flush.sh: line 173: [20091019011512: command not found The whitespace is significant in the command I showed: if [ `/bin/ls /dumps` != ] Except that this time you use dbl-quotes. I used singles as you did in the first reply, and it worked, with the added white space around the [ and ] as Paul pointed out. It may be that due to a proportionally spaced font here, that I missed that white space detail. Which is the most correct? '' or btw, the shell strips leading and trailing whitespace, so don't worry about the newline. ISTR reading as much, but CRS is becoming an issue. :) Dustin Thanks again. -- Cheers, Gene There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) The NRA is offering FREE Associate memberships to anyone who wants them. https://www.nrahq.org/nrabonus/accept-membership.asp In the force if Yoda's so strong, construct a sentence with words in the proper order then why can't he?
Re: Another oddity from Gene
On Mon, Oct 19, 2009 at 10:57:16 -0400, Dustin J. Mitchell wrote: The whitespace is significant in the command I showed: if [ `/bin/ls /dumps` != ] btw, the shell strips leading and trailing whitespace, so don't worry about the newline. However, if /dumps is empty, the above will return a parse error (at least in bash) since `/bin/ls /dumps` will be blank and so no string will be found on the left side of the != after command subsitution. Putting double quotes around it the invocation of ls seems to work both when /dumps is empty and when it isn't: if [ `/bin/ls /dumps` != ] Nathan Nathan Stratton Treadway - natha...@ontko.com - Mid-Atlantic region Ray Ontko Co. - Software consulting services - http://www.ontko.com/ GPG Key: http://www.ontko.com/~nathanst/gpg_key.txt ID: 1023D/ECFB6239 Key fingerprint = 6AD8 485E 20B9 5C71 231C 0C32 15F3 ADCD ECFB 6239