How can i create a link to my python script, which will execute it in console on double click?

Kinda simple task perhaps, but im too dumb to solve it by myself. I have a python script which helps me to make backups and i used just to doubleclick on its link on windows and start a dialog in cmd that way. How i can do the same on linux?

Well: what does your script look like?
Does it start with stating that it is a python script?
(does it call the python interpreter?
eg:
#!/usr/bin/python)

Is it executable?

Can you start it by calling it from a terminal?

Is it “in your $PATH” - does the shell try to execute it without giving the full PATH to it?

Does it work at all when you execute it with, eg:
sh -x /path/to/your_script
?

What does the “link” look like that you want to use to start/execute the script by clicking on it?
(it probably should be a “desktop” file - there is a certain grammar and syntax for those)

The script is neGit.py ( https://github.com/4Tipsy/neGit )
It can be run in terminal and i managed to do this via context menu of the linux
idk what is $PATH
i didnt run it directly from console(only from gui)

Link was created by doubleclick on desctop → create new → link to dir/file in a result it behaves like a file itself
there should be smth like “run in console” but i dont find it

omg some results!
now i managed to start it by adding this #! stuff into the script, but the console immidiatly closing after starting the script

but it opened the script, i saw the dialog start

Welcome to the forum! :wave:

What? Please see How to Post

A sincere effort to use modest and proper language and grammar is a sign of respect toward the community that will certainly be appreciated and is quite likely to elicit positive responses. Please refrain from using so-called “textspeak”, “netspeak”, “leetspeak” and all other forms of internet slang.

russian (or cyrillic charset language) is not my specialty to read and comprehend :wink:
I can read it - but understanding is a different matter
my knowledge of russian is very faint …

But I think your script should call that command.
What I mean is:
I don’t know the name and location of the script
but you should know that

and you should be able to call it via something like:
/usr/bin/python /path/to/that_script
using a terminal.

The result would help you to understand what is happening
if you at first tried to start/execute that script from a console/terminal session

and progress from there.

That is pretty easy to figure out …
this might even be the appropriate question to type into google :wink:

I have run the script via console and it worked!
But when i try to do this via link the console dies in very short time, by the way it doesnt happen when i run the script itself (very strange for me)
So problem is in link and i dont imagine how to fix that

… so you now need to provide details on what your link looks like.

It should make sure that the command to execute the script is executed in a terminal and it should perhaps stay open
rather than close
when the script is finished

Hard to say from the available information.

How do you run “the script itself”?

(what works, what doesn’t? …)

I still don’t know what this thing is even for (from it’s own description)
since I’m not able to understand any of the only russian documentation.

I just click on the script file, the default execution program is python
I remember i choose “run in console” in options but i cant find it now
before ive done it, executing the script leaded to the same problem

the script is just a dialog with python shutil at the end (with lots of additional stuff)

How about actually using the command line?
Open a terminal - and then you put in a command (the PATH to where it is) to execute the script?

There is no concrete information here as of now to get more detailed.

I dont want to run it from the terminal
The porpose of creating this script was making the backups in few clicks

There should be a way to make it work from a link, like… there should be a “run in console” option somewere

But it obviously doesn’t work.
So you need to troubleshoot.
Narrow down what might be wrong.

Using the terminal to do it seems to be the best option to me.
It’ll give helpful feed back.

This doesn’t mean that you need to use the terminal in the end.

But it’s useful to troubleshoot and get feedback.

… I’ll have to go in a few minutes and won’t be back before 9 pm tomorrow …

anyone else is welcome to help :wink:

I don’t know - this probably depends on what desktop environment you are using
to get advice on where to find that option - but:
you didn’t say yet …

I’d go for:
open terminal and use it to troubleshoot.
That is desktop independent.

When it actually works, started from a terminal,
then you can go and create your link/desktop file.
(my opinion …)

Ok, after some executions of the script i find out that it works as it should (with some strange behaviour on linux of course)

As i got, the problem is in link itself, because i had the same problem at first when i tried to run the script by double clicking on it
As i remembered, it was solved by turning on “run in console” option, but i dont remember where it is

I need to do the same with link, but as ive said, i cant find the “run in console” option

P. S. sorry for grammar mistakes, im writing this from my phone and it doest have any eng grammar check

So, as of now, it is like this:

it does work

… or does it not?

you just don’t know how/where to find the option to “run it in terminal”

I can’t tell you - I never use that feature - I always prefer the terminal over the graphical filemanager and it’s features like this.

And no one else can either, since you still did not share what DE or file manager you use. :wink:

in my native german
this process here is called:
die nötigen Informationen “aus der Nase ziehen”
(referring to a slow and tedious process … Google it if you like :wink: )

Of course I mean no offense - the phrase is always used in a slightly joking manner.

Cheers!
I’m gone now.

Well e better way would be creating a desktop file. Something like that:
Filename: what-ever-you-like.desktop

[Desktop Entry]
Name=Name of Application
Comment=My awesome application is great!
Exec=/path/to/application.py
Icon=/path/to/icon.png
Terminal=true
Type=Application
Categories=Utility;
Keywords=Search;Keyword;Application;Name;

Put it on the desktop or in ~/.local/share/applications (if should be visible at the menu)

1 Like

Still have the same problem, the console dies immediately, despite the fact that the code starts to run as it should :confused:

nevermind, i managed to solve it, thanks :grinning:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.