This forum has been archived. All content is frozen. Please use KDE Discuss instead.

difference between command-line and "GUI" invocation?

Tags: None
(comma "," separated)
edgue
Registered Member
Posts
65
Karma
0
OS
Hi there,

I am using the openafs client to connect to the AFS servers in our company.
I have a little python script that gets afs running for me (loading the kernel module, starting the afs daemon, requesting afs tokens). Now I have this:

- when I invoke the script on command line ... everything works perfect
- but when I invoke the script via "clicking it" (I put a link to it into my Desktop folder) ... one of the operations will fail. Fail looks like this:

1) i am ussing the kdialog window to query the afs password
2) next is to invoke a "piped" system call to the klog binary to request a token

step 2) fails when the script is invoked via "mouse click" ... gives me a bad return code that doesnt help a bit (i had the script print out the password; and it was OK, so its not that i am sending an invalid password).

So, my conclusion: there must be subtle differences between these two actions. Any idea what it could be?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Is the command to execute the script like the following:
Code: Select all
/bin/bash script.sh

Or are you directly clicking on the script? ( If you are then create a shortcut to it ( New > Link to Application ), only putting /bin/bash before the path to the script )


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
beermad
Registered Member
Posts
104
Karma
0
OS
Could it be that the script is dependent on some environment variables?

I have found that sometimes these can fail to be picked up from GUI invocation if a script doesn't explicitly point at a shell; for example having the following in the first line:
Code: Select all
#!/bin/bash

A script without this would inherit the shell environment if invoked from the command-line but may not from a GUI.


edgue
Registered Member
Posts
65
Karma
0
OS
My script starts with:

Code: Select all
#!/usr/bin/python


and I changed the "invocation style" to link ... using

/bin/bash -exec /home/myid/bin/start_afs.py

and I tried:

/home/myid/bin/start_afs.py

Finally, i got the thing running ... with "advanced -> run with terminal"
User avatar
beermad
Registered Member
Posts
104
Karma
0
OS
The fact that it works with "run with terminal" smells of environment problems, but I don't know Python so I've no idea what it does with environment variables.

Assuming Python has a way to list environment variables, I'd suggest running (from a GUI) a script to dump the environment to a file, then compare it with what you see when you list the environment from a terminal session.

If there's something obviously missing, you can force your script to pick it up either by explicitly setting it in the script or invoking it with (for example)
Code: Select all
DISPLAY=localhost:0 /path/to/script




Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]