I'm making an app via python with GUI.
I want to set a button that will connect to a specific path and run some commands at the server and leave the terminal open after he will finished running the commands.
I'm trying to send a several commands to CMD/MobaXterm with python,
I need to access a certain path with ssh, and add a command, like ls -l
Thanks.
Related
I have an embedded linux system that I need to run a python script whenever it boots. The python script needs to have a terminal interface so the user can interact and see outputs. The script also spawns another process to transfer large amounts of data over SPI, this was written in C.
I've managed to get the script to start on launch and have terminal access by adding
#reboot /usr/bin/screen -d -m python3 /scripts/my_script.py
to the crontab. I can then do "screen -r" and interact with the script. However if launched in this way the script fails to start the external SPI script. In python I launch the script with subprocess.Popen
proc=subprocess.Popen(["./spi_newpins,"-o","/media/SD/"+ latest_file"])
and this works perfectly whenever I manually launch the script, even within screen. Just not when it is launched by crontab. Does anyone have any ideas on how to get the spi subprocess to also work from crontab?
Fixed now, I had to add an absolute path to the spi_newpins function call
proc=subprocess.Popen(["/scripts/./spi_newpins","-o","/media/SD/"+ latest_file"])
I need to create a terminal/console program on my server compute and I want to connect to it with ssh from client. And I want to do it from a python script. So, I figured that I need to somehow have this script run the program (subprocess maybe?) and put it out on the socket.
How can I put out a certain program on a specified socket for ssh connection?
Can I even ssh to a certain program run in a console, not to a whole PC? I need client to have only acces to what I set up.
How can I put out a certain program on a specified socket for ssh connection?
I think that what you actually want to do is changing what is run when logging in with ssh.
You can do this in /etc/passwd by changing /bin/bash to the program you want to run when you log in. Do this for the user that you want to log in to via ssh.
I didn't understand if you wanted to log in from a python script or log in to a python program in an interactive shell, so:
You can use the paramiko library to log into a machine with ssh. (if that is what you want)
I need to create a terminal/console program on my server compute and I want to connect to it with ssh from client.
You can look at this project https://github.com/python-cmd2/cmd2 to build interactive console programs in python.
Im trying to gain an interactive shell via paramiko, I understand executing single commands via client.invoke_shell() and then sending a string on that channel, BUT im looking for a way to get a shell and stay on it, my purpose for this specifically is to launch a python script to get a netcat listener on my server and keep the shell session open so I can interact with the callback.
Normally, I would use "blender -P script.py" to run a python script. In this case, a new blender process is started to execute the script. What I am trying to do now is to run a script using a blender process that is already running, instead of starting a new one.
I have not seen any source on this issue so far, which makes me concern about the actual feasibility of this approach.
Any help would be appreciated.
Blender isn't designed to be started from the cli and to then keep receiving more commands from the cli as it is running. It does however include a text editor that can open text files and run the text block as a python script, it also includes a python console that can be used to interactively type in commands while blender is running. You may also find this addon useful as it lets you to run a text block in the python console, this leaves you with an interactive session that contains the variables as they exist at the end of the scripts execution.
There is a cli option to run blender as a python console blender --python-console - the gui does not get updated while this console is running, so you could open and exec several scripts and then when you exit the console, blender will update it's gui and allow interactive use, or if you start in background mode -b then it will quit when you exit the console.
My solution was to launch Blender via console with a python script (blender --python script.py) that contains a while loop and creates a server socket to receive requests to process some specific code. The loop will prevent blender from opening the GUI, and the socket will handle the multiple requests inside the same blender process.
Pretty much what the title says, I would like to be able to connect to a python process running under paster or uwsgi and utilize pdb functionality.
Using winpdb, you can attach to a running process like this:
Insert
import rpdb2; rpdb2.start_embedded_debugger('mypassword')
inside your script.
Launch your script (through paster or uwsgi) as usual.
Run winpdb
Click File>Attach
Type in password (e.g. "mypassword"), select the process.
To detach, click File>Detach. The script will continue to run, and can be attached to again later.