AforAlex
Posts: 85
Joined: Thu May 31, 2012 7:56 pm

SSH as console?

Sun Feb 02, 2014 8:24 pm

Hi, is it possible to SSH into the Raspberry Pi so that it logs into the Pi as if I had it connected up to the TV and accessing through the keyboard connected to the Pi?

The reason I ask is that I am working on a project which has a card reader connected to the Pi which is connected via USB and is picked up as a HID (so just sends through keyboard commands), and is located away from a TV, I want to be able to connect to the Pi and for it to run programmes (and wait for the commands from the reader) so that I can debug it easily.

At the moment I can connect on via SSH but I have to also unplug the reader from the Pi and plug it into my laptop for the input to pass through. Its all a bit of a pain at the moment to debug as have to keep on changing the configuration.

Does this make sense? is it possible to do what I want or is it a complete no?

Many thanks

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: SSH as console?

Sun Feb 02, 2014 9:36 pm

Hi,

After you log-in via SSH, execute as root:

Code: Select all

cat /dev/tty0
This command shall redirect data from your reader in the current SSH session.


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

AforAlex
Posts: 85
Joined: Thu May 31, 2012 7:56 pm

Re: SSH as console?

Sun Feb 02, 2014 10:53 pm

Hi, many thanks for this,

It kinda does what I need, but the problem is that I then can't type anything in from the ssh.

What I am trying to do is to logged in through SSH to start a python script, the python script is waiting for an input, and rather than the python script collecting the input through the ssh connection I want to to get its input from the connected card reader.

Can that work ?

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: SSH as console?

Mon Feb 03, 2014 12:00 am

Hi,
AforAlex wrote:It kinda does what I need, but the problem is that I then can't type anything in from the ssh.
... yes, because the cat command is running until you break it (with Control-C).
AforAlex wrote:What I am trying to do is to logged in through SSH to start a python script, the python script is waiting for an input, and rather than the python script collecting the input through the ssh connection I want to to get its input from the connected card reader.
I see. I haven't tested it, but you can try to open /dev/tty0 from the code. Open it as any other file. It is quite common that each record from the reader is listed in its own line on the screen (they are separated with a new line delimiter). Then you can use readline command to get the complete code record. Try something like this:

Code: Select all

reader = open('/dev/tty0', 'r', 0)
code = reader.readline()
reader.close()

Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
topguy
Posts: 5906
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: SSH as console?

Mon Feb 03, 2014 12:52 am

I would rather recommend to read directly from the input device that is the RFID reader.

When you plug it in and check the last messages from "dmesg" you should see a reference to /dev/input/event0 or similar. You should be able to open this device directly from Python. I dont know Python but search for something around Python and evdev.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: SSH as console?

Mon Feb 03, 2014 3:37 am

Didn't we have this same question sometime in the last couple of weeks?

And wasn't the answer then to use "screen", to setup a session running on the virtual console (i.e., /dev/tty1) and have it do whatever it is supposed to be doing and then connect into that screen session in "shared" mode (-x command line option) from the SSH session to monitor what's going on?

Ans isn't that same answer equally valid this time around?

And aren't we having fun playing "the question game" ?
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

AforAlex
Posts: 85
Joined: Thu May 31, 2012 7:56 pm

Re: SSH as console?

Mon Feb 03, 2014 11:10 am

I love you guys, thanks for the help and advice, will give it a try tonight and see which one works the best.

:-)

Return to “Beginners”