I have a (python) script that waits for user input.
I want to run that script on my raspberry PI that I access over an SSH connection.
I would like to capture the user input via the keyboard that is attached to my raspberry via a USB.
How could I achieve this? I only seem to be able to capture input from the machine that starts the ssh connection.
Related
I have a deep learning vm setup on google cloud platform. I ssh into by clicking the ssh button in my list of vm instances. The problem I am having is that if I run a program and close the ssh window while it is still running, when I ssh back into the vm, the program has been interrupted and the whole vm essentially has restarted.
Is there a way to setup my vm so that I can run a program and then close the ssh connection without it restarting the vm? I want to be able to run programs without being required to leave the ssh window open and my computer on.
As #Rup pointed out, processes belonging to your SSH session's shell will get a hang-up signal when you close the connection. To bypass the hang-up signal and let a program continue running, use the nohup command. Here is an example
nohup python test.py &
That will run the program test.py and as well as ignore the hang-up signal. The programs output will be stored in a nohup.out file.
I am new to Raspberry Pi. I have a Pi 2 kit model B.I am using an angry IP address and I can find Raspberry Pi's address using it. When I configure it using sudo raspi-config, make necessary changes and then say OK to reboot, I get this error in putty:
Server unexpectedly closed network connection.
How do I correct this issue?
Further, I have connected Raspberry Pi 2 with an Ethernet cable to the laptop. I have completed necessary steps like changing adapter settings, edited properties of Wi-Fi to allow other network users to connect to computers Internet connection but still I have no Internet access shown for unidentified Internet connection.
How can I solve this? Please suggest the necessary steps to be implemented
For me too many process and session running for a particular user is the cause of your problem so alternatively I logged in as root and ran the following commands:
ps -fp $(pgrep -d, -u adminuser)
pkill -9 -u adminuser
After this I can login normally in putty like ever before.
I am using Putty and Xming to SSH to a remote linux machine. I use screen so that I can keep things running in the background after I logout or a dropped connection.
However, when I reattach back to the screen subsequently, the display window of Xming is not shown. How can I get the display to show? Are there methods more suitable for my needs?
I have an xterm window open on a computer. I want to access this xterm window remotely using ssh. Is it possible? By access I mean, I should be able to run commands on that open shell.
I'm not sure if it is possible to access an xterm window that's already been opened, while being over ssh. However, you can certainly open an ssh connection with X11 forwarding capabilities. Once X11 is forwarded, you can just run the program in ssh's command line, and it'll open in your forwarded X11 screen.
Here's a good article that explains in detail what you need to accomplish this: http://www.math.umn.edu/systems_guide/putty_xwin32.html
For example, after completing the details in the above article, and assuming you have Gnome Desktop installed, you could run gnome-terminal over ssh and have a Unix terminal open and forwarded over the ssh connection. Pretty much any application that has a GUI is runnable this way.
here is my problem: i would like to run a Mathematica script through ssh on a remote machine so that i can close the terminal on my computer and keep it running on the remote one.
My problem arises because the script acts in interacting mode, and so when i close the terminal the process is shut down too.
Thanks.
Use tmux or GNU screen.
Workflow:
ssh into remote machine
start tmux/screen, e.g. tmux or screen
start Mathematica script inside tmux/screen session
detach tmux/screen session, e.g. Ctrl+B d (tmux) or Ctrl+A d (screen)
close ssh connection
Then later:
ssh into remote machine
reattach to tmux/screen session, e.g. tmux attach or screen -d -R
view completed Mathematica script output
Several cases:
If you don't need to interact with it or need to visualize the notebook during evaluation
Log in to the machine with ssh
Then, to run a kernel in the background and detach it from the current session, use nohup tool (the standard output of the command will be dumped to myNotebook.out):
nohup math < myNotebook.nb > myNotebook.out &
At this point, the ssh session can be closed without killing Mathematica
Optionally you can monitor mathcommand output with the tail command (use CTRL-C to exit the tail monitoring)
tail -f myNotebook.out
If you need to see what's going on, visualize graphs during calculation or to be able to interact graphically, use remote desktop (vnc) and tunnel your communication with remote machine. Details depends a bit on the Linux distribution (vnc clients & servers may differ). You can even from Windows or Mac connect with remote desktop to your linux box and manipulate it. I suggest you to search the web for remote desktop ssh tunnel + your distro for tutorials.