it is an executable (I made it an executable from the properties) and I can run it from a console with ‘./program’. But when I double-click on the file nothing happens. I thought that was the whole point making it executable. Otherwise I can type the command itself in a console. Does anyone know how to make it run by clicking the mouse rather than from a console? Thank you.
The directory where the shell script resides and the current directory at execution time are different things. There are codes you can use in shell scripts to find the directory where it lives and then you can chdir there or to prepend that directory to any filenames.
Guys, thank you but I would like a solution not a theory on how it’s possible to do things.
I don’t want to include full path if it’s possible
The shell script will either be in the same folder as the python script or the Python script will at least be in a relative folder
I don’t want to write a whole program in another script. What’s the point writing a script for a script? I just want to run my Python script by clicking a mouse. Otherwise the user can always run it directly from a console.
There’s a Py-exe or something like this in windows to make an executable out of a script. Is there anything like this in Linux?
Is that possible? Or the only option is what you have already told me - to write a bigger shell script with folder searches and everything? If you have an example, I’d appreciate it, it’ll save me a lot of time. Thank you.
You look at $0 of the script. That will either be the full path or a relative path. That will give you the directory the script lives in. By your convention, that will also be where the Python program is.
I do not really understand why you write a bash script to start a python
script. It is much more easier to run a python script by making it
executable the proper way
That worked like a charm! That’s exactly what I was looking for. Thank you very much.
I wrote a(nother) wrapper for ffmpeg in C# for Mono on Linux and learnt that many don’t like running Mono on Linux. That’s fine. So I ported my whole app from C# to Python. And learnt Python on the way - it’s such a great language, I’m hooked now.
If you would like to have a look at my video/audio/image codec app, please visit the SourceForge site: Cute Giraffe | Get Cute Giraffe at SourceForge.net and download the PyQt version. But bear in mind it’s only the beginning of development and it has just the basic functionality which I plan to extend in the near future.