Re: Bash script Slack >> Deb-Etch
- From: Handover Phist <jason@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 07 Nov 2006 20:30:46 GMT
On 2006-11-07, Dean G. <dguttadauro@xxxxxxxx> wrote:
Handover Phist wrote:
On 2006-11-07, John-Paul Stewart <jpstewart@xxxxxxxxxxxxxxxx> wrote:
Handover Phist wrote:
I have a million little simple scripts doing chores for me, and I've
just switched a box from Slackware 11.0 to Debian Etch. The script in
question is this:
#!/bin/bash
LENGTH=6
while [ ${LENGTH} -ge 5 ]
do
/usr/games/fortune -aes > ~/.signature
echo >> ~/.signature
echo "http://www.websterscafe.com" >> ~/.signature
LENGTH=`wc -l ~/.signature | cut -d " " -f 1`
done
exit 0
It worked in Slack, but in Etch repeats "wc -l ~/.signature | cut -d " "
-f 1" endlessly. I have no idea why, as the versions of BASH are the
same.
Put 'set -x' as the second line and run the script. You'll see exactly
what is going on in the script.
Hey, good idea:
-------------
++ wc -l
+ LENGTH=5
+ '[' 5 -ge 5 ']'
+ /usr/games/fortune -aes
+ echo
+ echo http://www.websterscafe.com
wc -l < ~/.signature
++ wc -l
+ LENGTH=5
+ '[' 5 -ge 5 ']'
+ /usr/games/fortune -aes
+ echo
+ echo http://www.websterscafe.com
wc -l < ~/.signature
++ wc -l
+ LENGTH=5
+ '[' 5 -ge 5 ']'
-------------
Out of curiousity, what is the shortest length of anything in fortune ?
There are plenty of one liners:
jason@jason:~$ fortune -aes
Money cannot buy love, nor even friendship.
I've been using this script in Slack for a couple of years now.
You have fortune + echo + url. If everything in fortune is at least
three lines, it will continue forever. Maybe you just need to adjust
your value in the test. If fortune outputs blank lines before and after
the quotes, then you will always have at least 5 lines. Also, perhaps
you could run the loop before you add your url. It seems inefficient to
add the url and blank line every time in the loop, when it could just
be added once at the end after everything else checks out.
Dean G.
I dont pretend to know why, but that works:
-------------------------------
#!/bin/bash
LENGTH=6
while [ ${LENGTH} -ge 3 ]
do
/usr/games/fortune -aes > ~/.signature
LENGTH=$(( wc -l ~/.signature | cut -d" " -f1 ))
done
echo >> ~/.signature
echo "http://www.websterscafe.com" >> ~/.signature
exit 0
------------------------------
That script works while the first one didn't.
--
BOFH excuse #163:
no "any" key on keyboard
http://www.websterscafe.com
.
- References:
- Bash script Slack >> Deb-Etch
- From: Handover Phist
- Re: Bash script Slack >> Deb-Etch
- From: John-Paul Stewart
- Re: Bash script Slack >> Deb-Etch
- From: Handover Phist
- Re: Bash script Slack >> Deb-Etch
- From: Dean G.
- Bash script Slack >> Deb-Etch
- Prev by Date: Re: What is going on with Open Office? So many BUGS!
- Next by Date: Re: chkrootkit finding 2 infected files
- Previous by thread: Re: Bash script Slack >> Deb-Etch
- Next by thread: Re: Bash script Slack >> Deb-Etch
- Index(es):
Relevant Pages
|