Access Denied when launching a Shell file
Posted
#1
(In Topic #1165)
Regular

When the "Launch" button is pressed, this code would launch an external Python script.
It worked just fine for some time. Now whenever I try to get Gambas3 to run an external Python file (any file),
I get the error message shown below referring to : Permission denied.
Does anyone have an idea why this happens and what may be the solution?
ERROR MESSAGE in the debug window….
/bin/sh: 1: /home/veggie/Desktop/CallOptionCalc/python3/DoAnalysis: Permission denied
Posted
Regular

Posted
Guru

sarpomira said
Hi All,
When the "Launch" button is pressed, this code would launch an external Python script.
It worked just fine for some time. Now whenever I try to get Gambas3 to run an external Python file (any file),
I get the error message shown below referring to : Permission denied.
Does anyone have an idea why this happens and what may be the solution?
ERROR MESSAGE in the debug window….
/bin/sh: 1: /home/veggie/Desktop/CallOptionCalc/python3/DoAnalysis: Permission denied
is the files executable flag set?
If not you'll have to use
Shell "python " & FileAppPath
or Exec ["python", FileAppPath]
or make it executable for it's shebang line to work as expected.
chmod +x /home/veggie/Desktop/CallOptionCalc/python3/DoAnalysis.py
Posted
Guru

Change the Shell your app uses to bash like this..
but often when an archive is unpacked somewhere all the +x flags get removed from scripts. (it's probably just that) using the python command to launch them or making the scripts executable should fix it for you.
Posted
Regular

I created a "Hello World" script called Hello.py and placed it on the desktop.( It runs fine in the linux shell)
When I call the file from Gambas using "Shell" I get the following error.
/home/veggie/Desktop/Hello.py: 1: Syntax error: word unexpected (expecting ")")
I don't know if this is a Gambas error or an OS error.?
Code (gambas)
- 'Path to the external Python Script
- 'Specify the command to run the Python script
- FileAppPath = "/home/veggie/Desktop/Hello.py"
- 'check if file is executable and set x flag if not...
- 'if Not InStr(Stat(FileAppPath).Perm.User, "x") Then Exec ["chmod", "+x", FileAppPath] Wait
- 'Launch the external application
- Shell FileAppPath
- 'Shell "python" & FileAppPath
PS: I ran the program with the various "chmod" and Shell lines shown above but the result is still "access denied" or expecting ")"
Posted
Guru

I just made a quick helloworld.py in $HOME
<HIGHLIGHT highlight="python">
#!/usr/bin/env python
print ("hello world")
</HIGHLIGHT>
Terminal went like this..
Code
bonus:~$ ~/helloworld.py
bash: /home/bonus/helloworld.py: Permission denied
bonus:~$ chmod +x ~/helloworld.py
bonus:~$ ~/helloworld.py
hello world
And running Shell "~/helloworld.py" in gambas printed "hello world" to console as expected.
Does the file in question have a shebang line as it's first line?
#!/usr/bin/env python
If it is something normally launched by something else the something else may know it is a python script and a shebang line was never added.
if not it will need to be run explicitly with python.
Ps. your commented Shell command
'Shell "python" & FileAppPath
Should be
'Shell "python " & FileAppPath
(a space after python)
You could maybe do some manual handling..
Something like that ?
Posted
Guru

that'd be a "you" error
print "hello world"
that's wrong with python
print ("hello world")
that's correct.
1 guest and 0 members have just viewed this.


