0

Hi I have a bash script:

#!/bin/bash

declare -a list1
declare -a list2

list1=("Hello" "there" "honey")
list2=("More" "strings" "here")

declare -a joined

joined=($(./pytest.py ${list1[@]} ${list2[@]}))
echo ${joined[@]}

Following is the python code pytest.py:

#!/usr/bin/python

import sys

for i in sys.argv:
print "hi"

The error I get is this:

./pybash.sh: line 11: ./pytest.py: Permission denied

I have used the following to set the permission of the shell script:

 chmod +x pybash.sh

It still gives me the same error. What am I doing wrong?

4
  • 1
    Or you could simply call the joined with python ./pytest.py instead of simply pytest.py Commented Oct 30, 2013 at 21:39
  • Also, try adding a shebang line. #!/usr/bin/env python so that the shell knows what to execute the script with. Commented Oct 30, 2013 at 21:39
  • 1
    you need to chmod +x pytest.py and add the shebang @dwerner mentions. Commented Oct 30, 2013 at 21:52
  • Notice that he's actually got the shebang line already, it's just not properly inside the code block. Commented Oct 30, 2013 at 22:05

3 Answers 3

3

Do the chmod on your pytest.py file if you intend to execute it.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 for pointing out which file still needs to have its permission bit set.
3

Perhaps adding :

#!/usr/bin/python

at the start of your python script will fix the problem ?

1 Comment

This fixes a problem that hasn't been exposed yet :)
1

Adding a shebang (#!/dir/dir) to the top of your script will not fix the problem completely.

You need to change the modification of the file in order to execute.

There are a few different modifications you can make with the chmod command, but my favorite is:

chmod 755 filename.py

755 Allows the owner to read, write, and execute the file. Any other users can only read and execute.

Check out http://linuxcommand.org/lc3_lts0090.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.