pythonsshwifilego-mindstorms-ev3

ssh passing and receiving a variable value instead of a file


I'm working on a windows with python. My SSH server is a Mindstorm EV3, That is basically an Linux based embedded pc that supports SSH over network. I'm able to connect to the server and download or upload files. My server reads this files with the basic

file.open("filename", "w")

no problem. But isn't there an easier way to pass a value from my computer to my embedded pc other than uploading a file and reading it then out?

How do I send a value using SSH from my windows (python paramiko, PuTTY, etc.) And what do I need to write on my Server to receive this value? (SSH script should be enough, I'll be able to figure out how to do this with python running right there.)

I'm very new to everything containing SSH and passing data over my WiFi. Thank you all for your help !


Solution

  • You can use the system module to do command line arguments. This will allow you to run your code as script.py arg1,arg2,.

    This will pass in all the arguments as a list of strings. Also be aware that file name will be passed in as the zeroth element.

    This is an example of how to use it.

    import sys
    
    for i in sys.argv:
        for j in i:
            print j + '\n'
    

    With an input python s.py foo bar It will print

    s
    .
    p
    y
    f
    o
    o
    b
    a
    r