Page 1 of 1

Can I SSH to Pi using Putty, then use Python Command Line?

Posted: Wed Jan 20, 2016 1:04 am
by some_evil
Hi All,

I usually use my PC to SSH onto my Pi using PuTTy, which is great.

When I want to run a simple python line I always use

Code: Select all

sudo nano newCode.py
Add my code... then run using:

Code: Select all

python newCode.py
and I get my output....

Sometimes I have to create the above python file to run a single line, this is time consuming.

Is there a way to enter some form of Python Command Line over this SSH connection???

Thanks

Re: Can I SSH to Pi using Putty, then use Python Command Lin

Posted: Wed Jan 20, 2016 6:22 am
by elatllat
Try -c as noted in

man python

http://linux.die.net/man/1/python

Re: Can I SSH to Pi using Putty, then use Python Command Lin

Posted: Wed Jan 20, 2016 6:22 am
by SonOfAMotherlessGoat
Have you tried IDLE or just typing `python` at the command prompt to get the python CLI?

Re: Can I SSH to Pi using Putty, then use Python Command Lin

Posted: Wed Jan 20, 2016 7:00 am
by rpdom
some_evil wrote:When I want to run a simple python line I always use

Code: Select all

sudo nano newCode.py
Why do you use sudo here? It shouldn't be needed at all.

Using sudo with nano will create file that is owned by the user "root", instead of your "pi" user. That is pointless (unless you are editing system files) and can cause permission problems.

Re: Can I SSH to Pi using Putty, then use Python Command Lin

Posted: Wed Jan 20, 2016 7:15 am
by some_evil
sorry that was way easier than I imagined... i feel stupid now, simply typing python (nothing after it) will enter the command line for python.. works perfectly.

And yes you are correct, sudo is redundant in my example.

Thanks for the help guys, greatly appreciated, you just saved me plenty of wasted hours creating .py files for nothing! haha :roll: