User avatar
kaybee
Posts: 2
Joined: Tue Dec 02, 2014 4:18 pm

linux/usage/scripting

Mon Dec 08, 2014 5:48 pm

Follwing the instructions at http://www.raspberrypi.org/documentatio ... ripting.md, results in:

./fun-script: line 1: 1: command not found

I am Using Raspbian, on Raspberry Pi B. Any ideas?

Thanks,

kaybee

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: linux/usage/scripting

Mon Dec 08, 2014 6:33 pm

Are you sure that link is correct? I get a 404 error...

Gr
Dirk.

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: linux/usage/scripting

Mon Dec 08, 2014 6:40 pm

I checked the docs on github...

Did you maybe type 'While' instead of 'while'?

Gr.
Dirk.

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: linux/usage/scripting

Mon Dec 08, 2014 7:51 pm

I just tried the script as shown and got the same result.

Changing it from

Code: Select all

while 1
do
echo Raspberry Pi!
done
to

Code: Select all

while true
do
echo Raspberry Pi!
done
works

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: linux/usage/scripting

Mon Dec 08, 2014 9:16 pm

The man page for /bin/bash says the argument to while must be a command: it is the return status of that command that is checked. Presumably an integer is not processed as a command and does not have a return value.

I have raised this as an 'Issue' on the github site for the RPF documentation. https://github.com/raspberrypi/documentation/issues/134

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: linux/usage/scripting

Mon Dec 08, 2014 10:20 pm

Incidentally, the more "idiomatic" way to do this is:

Code: Select all

while :;do
…
done
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: linux/usage/scripting

Tue Dec 09, 2014 8:59 am

The tutorial referred to has now been corrected.

User avatar
kaybee
Posts: 2
Joined: Tue Dec 02, 2014 4:18 pm

Re: linux/usage/scripting

Tue Dec 09, 2014 1:03 pm

All:
Thanks guys, being new to this, I was confused. It's interesting that:

while true
do
echo Raspberry Pi!
done

was actually corrected to:

while :
do
echo Raspberry Pi!
done


on the tutorial. Both work.

Thanks again

Return to “General programming discussion”