473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Now what!?

Grrr....

I'm following A Byte of Python and into the while loops chap. I cp/paste
while.py to a file and give 777 perms. I mv while.py to while and run it (./while)
as a standalone script. I get errors.

Here is the script:

while.py

http://www.ibiblio.org/swaroopch/byt...statement.html
When I run it as.....

$ python while

......it works perfect. But, if I run it simply as.....

$ ./while

......I get this:

$ ./while
number: illegal number: =
../while: line 6: running: command not found
../while: line 9: syntax error near unexpected token ('
../while: line 9: guess = int(raw_input('Enter an integer : '))'

Why does it work one way and not the other. If I run the simple hello world
script the same way ($ ./helloworld) and it works fine. Same shebang, same
dir, same permission, etc. I even meticulously indented everything
perfectly by hand. What am I missing?

BTW, anyone know a better cli news client/editor combo than slrn/jed (don't
even think vi!)? When I cp/past code (or most anything else) to jed, all
the lines become stair-stepped. This is no biggie for a most stuff, but for
idented code, it's unacceptable.

nb

Jun 27 '08 #1
13 1432
notbob schrieb:
Grrr....

I'm following A Byte of Python and into the while loops chap. I cp/paste
while.py to a file and give 777 perms. I mv while.py to while and run it (./while)
as a standalone script. I get errors.

Here is the script:

while.py

http://www.ibiblio.org/swaroopch/byt...statement.html
When I run it as.....

$ python while

.....it works perfect. But, if I run it simply as.....

$ ./while

.....I get this:

$ ./while
number: illegal number: =
./while: line 6: running: command not found
./while: line 9: syntax error near unexpected token ('
./while: line 9: guess = int(raw_input('Enter an integer : '))'

Why does it work one way and not the other. If I run the simple hello world
script the same way ($ ./helloworld) and it works fine. Same shebang, same
dir, same permission, etc. I even meticulously indented everything
perfectly by hand. What am I missing?
I'm pretty sure you misse the correct shebang - the shell tries to
execute your script as shell-script, instead of invoking the interpreter.

Diez
Jun 27 '08 #2
Diez B. Roggisch escribió:
notbob schrieb:
>Grrr....

I'm following A Byte of Python and into the while loops chap. I cp/paste
while.py to a file and give 777 perms. I mv while.py to while and run
it (./while)
as a standalone script. I get errors.

Here is the script:

while.py

http://www.ibiblio.org/swaroopch/byt...statement.html
When I run it as.....

$ python while

.....it works perfect. But, if I run it simply as.....

$ ./while

.....I get this:

$ ./while
number: illegal number: =
./while: line 6: running: command not found
./while: line 9: syntax error near unexpected token ('
./while: line 9: guess = int(raw_input('Enter an integer : '))'

Why does it work one way and not the other. If I run the simple hello
world
script the same way ($ ./helloworld) and it works fine. Same shebang,
same
dir, same permission, etc. I even meticulously indented everything
perfectly by hand. What am I missing?

I'm pretty sure you misse the correct shebang - the shell tries to
execute your script as shell-script, instead of invoking the interpreter.

Diez
--
http://mail.python.org/mailman/listinfo/python-list
Add #!/path/to/bin/python on the first line of your script.

Also should work with:
#!/usr/bin/env python
Jun 27 '08 #3
On 2008-05-10, Diez B. Roggisch <de***@nospam.web.dewrote:
notbob schrieb:
>script the same way ($ ./helloworld) and it works fine. Same shebang, same
dir, same permission, etc.

I'm pretty sure you misse the correct shebang -
Sorry. Both exactly the same. I checked 5 times.

helloworld shebang: #!/usr/bin/python
while shebang: #!/usr/bin/python

(above yanked from respective scripts)

nb
Jun 27 '08 #4
On 10 ÍÁÊ, 21:22, notbob <not...@nothome.comwrote:
On 2008-05-10, Diez B. Roggisch <de...@nospam.web.dewrote:
notbob schrieb:
script the same way ($ ./helloworld) and it works fine. Same shebang, same
dir, same permission, etc.
I'm pretty sure you misse the correct shebang -

Sorry. Both exactly the same. I checked 5 times.

helloworld shebang: #!/usr/bin/python
while shebang: #!/usr/bin/python

(above yanked from respective scripts)

nb
Shebang is certainly broken, possible causes:
1. Wrong line endings (should be \n)
2. Whitespace before the shebang

-- Ivan
Jun 27 '08 #5
On 2008-05-10, Ivan Illarionov <iv*************@gmail.comwrote:
Shebang is certainly broken, possible causes:
1. Wrong line endings (should be \n)
Nope. Not it.
2. Whitespace before the shebang
BINGO! ....we have a winner. ;)

I thought for sure that was not correct. No white space before the
sheba.... Wait a minute! Howzabout a blank line above the shebang? D0H!!

These are the minute details that bedevil the poor noob. I've read dozens
of tutorials on different prog langs and have never read a single thing on
white space or blank lines preceding a shebang. Till now. I always get
frustrated and give up on learning programming, not really caring much for
coding, anyway. But, dammit, I'm gonna stick with it this time. I'll learn
python if it kills me! ....that is, if you folks can stand all my dumb
questinons. ;)

Thank you, Ivan, and other repondents.

nb ....back to while loops

Jun 27 '08 #6
On 2008-05-10, notbob <no****@nothome.comwrote:
BTW, anyone know a better cli news client/editor combo than slrn/jed (don't
even think vi!)? When I cp/past code (or most anything else) to jed, all
the lines become stair-stepped. This is no biggie for a most stuff, but for
idented code, it's unacceptable.
Whoo-hoo! I just got emacs config'd to do python. Let's see how that works.

nb
Jun 27 '08 #7
On 2008-05-10, Dennis Lee Bieber <wl*****@ix.netcom.comwrote:
>These are the minute details that bedevil the poor noob. I've
read dozens of tutorials on different prog langs and have
never read a single thing on white space or blank lines
preceding a shebang. Till now. I always get

Well... The "shebang" line is OS and shell specific
The "#!" is sort of a holdover from the "magic number" used
back in the day on Unix systems. Traditionally, the type of an
executable file on Unix systems was determined by a "magic
number" that was read from the first two bytes of a file:

http://en.wikipedia.org/wiki/Magic_number_(programming)

Back then there was a text file somewhere that listed the
various 16-bit values and what they meant. The "file" program
used that list to guess what a file was. It's gotten
considerably more complex since then, and the "magic" file has
syntax to specify fairly large/complex patterns that are used
to determine file types. If you're curious, there's probably a
"magic" file somewhere on your system. On Gentoo it's at
/usr/share/misc/file/magic,

On a Linux system (and I presume on other Unixes), the kernel
itself (if built with the proper options) knows know how start
a "script" file that starts with the characters "#!". When the
kernel is told to execute a file whose first two bytes are "#!"
(0x32,0x21), it knows to read the newline terminated path of an
executable starting at the byte following the "!" (the third
byte in the file). The kernel then executes that file,
appending the name of the original "script" file to the argv
list.

--
Grant Edwards grante Yow! My mind is making
at ashtrays in Dayton ...
visi.com
Jun 27 '08 #8
On 2008-05-10, Dennis Lee Bieber <wl*****@ix.netcom.comwrote:
So... in short, you'd need to have been reading a tutorial specific
to "shell" scripting...
I have been. I'm also trying to learn bash shell scripting, not to mention
sed/awk, php, etc. I should have started this a long time ago, but I'm lazy
and, like I said, I'm not particularly fond of coding. Yes, I have learned
basic C and basic , but never beyond intro. Now, I'm doing it because I'm a
geezer and I figure my brain needs more exercise then just blabbing on
usenet. Besides, I've been cruising while using linux for too long and have
remained low end intermediate. Time to get serious. Pass the cheat sheets!

nb
Jun 27 '08 #9
On May 10, 8:22*pm, notbob <not...@nothome.comwrote:
On 2008-05-10, Dennis Lee Bieber <wlfr...@ix.netcom.comwrote:
* *So... in short, you'd need to have been reading a tutorial specific
to "shell" scripting...

I have been. *I'm also trying to learn bash shell scripting, not to mention
sed/awk, php, etc. *I should have started this a long time ago, but I'm lazy
Throw all of this away and learn just python. That will be much
simpler for you.
and, like I said, I'm not particularly fond of coding. *Yes, I have learned
basic C and basic , but never beyond intro. *Now, I'm doing it because I'm a
Forget basic and learn python. Later you can learn C.
geezer and I figure my brain needs more exercise then just blabbing on
usenet. *Besides, I've been cruising while using linux for too long and have
remained low end intermediate. *Time to get serious. *Pass the cheat sheets!

nb
Jun 27 '08 #10
On 2008-05-11, Dennis Lee Bieber <wl*****@ix.netcom.comwrote:
on the Amiga, it could be any of those applications).
ahhh.... the Amiga, the demise of which was one of the great calamaties of
our cyber time. (sniff)

nb
Jun 27 '08 #11
On May 10, 10:05*pm, hdante <hda...@gmail.comwrote:
On May 10, 8:22*pm, notbob <not...@nothome.comwrote:
On 2008-05-10, Dennis Lee Bieber <wlfr...@ix.netcom.comwrote:
* *So... in short, you'd need to have been reading a tutorial specific
to "shell" scripting...
I have been. *I'm also trying to learn bash shell scripting, not to mention
sed/awk, php, etc. *I should have started this a long time ago, but I'm lazy

*Throw all of this away and learn just python. That will be much
simpler for you.
and, like I said, I'm not particularly fond of coding. *Yes, I have learned
basic C and basic , but never beyond intro. *Now, I'm doing it becauseI'm a

*Forget basic and learn python. Later you can learn C.
Fiscally speaking, C and Python may well be just as economical. So
long as you've spent time learning a computer language, hold you can
get your needs met*.

* Even if money isn't a measure of value, a true measure of value, or
measure of true value.

In light of the actual writing of Python, if you make it, like to.

In sight of competitors, argue that Python is at least a locus, node,
nodepoint, or to-central of something about free and software.

Hold that Python is an end in itself, and/or that writing it is, and/
or is writing an implementation.

(Can you talk about languages like they're people?)

Distinguish further between languages, programs, libraries, and the
standards.

Then evaluate Python for population assortment characteristics, such
as population, overcrowding, undercrowding, and various sense
criteria.

In the Windows world, we are asking, how many keystrokes per thought,
mouse motions per error, and cross.

If your boss sucks but Python rules, it remains unclear that either is
any better. It is not clear that Python has a will, or computers
have.

If they have minds, whether absent will or not, perhaps it wouldn't
pay to like it too much. What diversity can you find on a newsgroup?
>

geezer and I figure my brain needs more exercise then just blabbing on
usenet. *Besides, I've been cruising while using linux for too long and have
remained low end intermediate. *Time to get serious. *Pass the cheatsheets!
nb- Hide quoted text -

- Show quoted text -
Jun 27 '08 #12
I don't know the context of the discussion, since I just joined the
list, but:
On May 10, 2008, at 11:05 PM, hdante wrote:
On May 10, 8:22 pm, notbob <not...@nothome.comwrote:
>On 2008-05-10, Dennis Lee Bieber <wlfr...@ix.netcom.comwrote:
>> So... in short, you'd need to have been reading a tutorial
specific
to "shell" scripting...

I have been. I'm also trying to learn bash shell scripting, not to
mention
sed/awk, php, etc. I should have started this a long time ago, but
I'm lazy

Throw all of this away and learn just python. That will be much
simpler for you.
Ummm, if you are working with Unix and Unix-like systems, you should
know shell scripting. Work through that first and then when you find
that you can't get things done with a shell script, go with Python (or
failing that, Perl :) ).

- Rilindo
Jun 27 '08 #13
notbob wrote:
frustrated and give up on learning programming, not really caring much for
coding, anyway. But, dammit, I'm gonna stick with it this time. I'll learn
python if it kills me!
No, it won't kill you but make you stronger ;)
Jun 27 '08 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: thecrow | last post by:
Alright, what the hell is going on here? In the following code, I expect the printed result to be: DEBUG: frank's last name is burns. Instead, what I get is: DEBUG: frank's last name is...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
12
by: Dario | last post by:
The following simple program behaves differently in Windows and Linux . #include <stdexcept> #include <iostream> #include <string> using namespace std; class LogicError : public logic_error {...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
47
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
8
by: Midnight Java Junkie | last post by:
Dear Colleagues: I feel that the dumbest questions are those that are never asked. I have been given the opportunity to get into .NET. Our organization has a subscription with Microsoft that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.