473,498 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sh: test: argument expected

Hi,

I am a new user of python. I ran
a python script and I got the
following message:

sh: test: argument expected

I found that this error came from a
line in the script:
energy = atoms.GetPotentialEnergy()

I looked for a solution to this
problem in Internet and I found
(http://www.experts-exchange.com/Oper..._20706303.html)
that the problem was that the variable
was not initialised. I also found
that the bash shell initialises the variables
automatically and the Bourne shell (sh) does not.
(http://www.experts-exchange.com/Oper..._20706303.html)

I suppose that 'sh:' in the error message
means that the script is using the Bourne shell,
and hence, I understand the message error.

However, I was using the bash shell in the computer
I ran the script, not
the Bourne shell (sh). Hence, I do not
understand the 'sh:' in the error message.
Could be that python scripts are using by default the
Bourne shell?

The first line of the python script is:
#!/usr/bin/env python

Thanks in advance.
Jul 18 '05 #1
1 3266
Iván Cabria wrote:
Hi,

I am a new user of python. I ran
a python script and I got the
following message:

sh: test: argument expected

I found that this error came from a
line in the script:
energy = atoms.GetPotentialEnergy()

I looked for a solution to this
problem in Internet and I found
(http://www.experts-exchange.com/Oper..._20706303.html)
that the problem was that the variable
was not initialised. I also found
that the bash shell initialises the variables
automatically and the Bourne shell (sh) does not.
(http://www.experts-exchange.com/Oper..._20706303.html)

I suppose that 'sh:' in the error message
means that the script is using the Bourne shell,
and hence, I understand the message error.

However, I was using the bash shell in the computer
I ran the script, not
the Bourne shell (sh). Hence, I do not
understand the 'sh:' in the error message.
Could be that python scripts are using by default the
Bourne shell?

The first line of the python script is:
#!/usr/bin/env python

Thanks in advance.

Question 1: if you run the script using "python scriptname.py" does the
error go away? If so then your script is being executed by the shell and
not by the python interpreter.

Question 2: Are there any blank lines or empty spaces before
#!/usr/bin/env python ?

regards
Steve
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
Jul 18 '05 #2

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

Similar topics

1
536
by: Iván Cabria | last post by:
Hi, I have run the script using "python scriptname.py" and the error does not go away. I got the same error: sh: test: argument expected I have checked again that the first line of the...
0
1340
by: Iván Cabria | last post by:
Hi, in the help page of env (man env) we can find: ... ... /usr/bin/env If env executes commands with arguments, it uses the default shell /usr/bin/sh (see sh(1)). ... ...
0
1170
by: Iván Cabria | last post by:
Hi, thanks to Jeff Epler for the answer. I have tried his suggestion and I have added two lines after the first line in the python script: import os os.environ = "/bin/bash"
0
1199
by: Iván Cabria | last post by:
Hi again, I have checked that the shell is the bash shell by running again the script with a print statement. The first four lines are: #!/usr/local/bin/python import os os.environ =...
6
2673
by: Ben Finney | last post by:
Howdy all, Summary: I'm looking for idioms in unit tests for factoring out repetitive iteration over test data. I explain my current practice, and why it's unsatisfactory. When following...
27
3740
by: Josh | last post by:
We have a program written in VB6 (over 100,000 lines of code and 230 UI screens) that we want to get out of VB and into a better language. The program is over 10 years old and has already been...
1
17020
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
176
8184
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
3
1576
by: JanW | last post by:
Somewhat a C++ beginner, I'm trying to make a general test function that could test unary operators (or methods) of an object of any class. Arguments are a member-pointer to the function, a...
0
7121
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
7162
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
7197
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...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4584
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.