I am using a Raspberry Pi zero that runs on Rasbpian, and am connecting it with a computer, through a transceiver. I use minicom on the Raspberry Pi and Putty on the laptop to second documents.
I wrote some code that automatically generates files in a folder, and want to send those files through serial to my laptop the moment they are generated. I've heard that I can use rsync for this, but only read about people using it with SSH. One friend advised using piping, but I am new to this, so did not understand how to use piping with rsync.
Related
I'm making an rpi based terminal in python and I want to run a powershell command on my computer. How can I send a command to a usb device
You could run socat on your Windows PC to read from serial and execute whatever you receive - if you like big security holes😉 Try adding socat tag to attract the right folk if that's an option.
Or you could run a Python script that sits in a loop reading from serial and then using subprocess.run() to execute the commands it receives.
I'm having a pc that i have a python script on it that uses Gui (moves the mouse while searching some opjects). - PC #1
I need to operate this script from another pc (PC #2) in an automation script (that process is just one of the steps, which repeats a lot, but the only one i have issue with).
both are operating with windows.
PC1 can get connection from SSH. and i need to open this script using the PC2. But this script doesn't operate due to gui i think. it's similar to why for example i can't open Matlab or any othe app in PC1 using SSH.
Any way to do it?
Wasn't able to find an answer online. at the moment i use SSH from PC2 (connected using python) to be used with PC1 to run a specific gui locally.
So, I want to be able to write Python code in my Visual Studio Code on my Windows PC. On my network is a raspberry pi 4, which I would like to execute said code on and receive any errors or output from.
Is it possible for me to write some python code on my Windows PC, "run" it on the Raspberry pi, and receive any outputs of the program on my Windows PC?
The reason I wish to do this is that Visual Studio Code generally helps me write any code, and it is more time consuming for me to use other IDE's, and my code uses PyBluez, something I can't just test on my Windows PC (which has no Bluetooth module)
I hope my question is in the right format and such! This is my first time posting! Any comments appreciated!
Yes you can do that, but it might not be very straight forward. In order to achieve this, you need your Raspberry Pi to be on the same network as your Windows PC (i.e. on the same WiFi network or connected via Ethernet). Then you need to get the IP address of your Raspberry Pi through the following command:-
ifconfig -a
The IP address will be of the following format: W.X.Y.Z
Now from your Windows PC, you can send your python script/scripts through the following command from cmd:-
scp script.py pi#W.X.Y.Z:/home/
And then you can access your Raspberry Pi and run the program by sshing into it through the following commands from cmd:-
ssh pi#W.X.Y.Z
You'll need to enter the Raspberry Pi's password for both commands above, but after that you should have your script on your Pi and you should be able to run it there from your Windows PC.
The links below have more verbose explanation:-
https://www.raspberrypi.org/documentation/remote-access/ip-address.md
https://www.raspberrypi.org/documentation/remote-access/ssh/scp.md
https://www.raspberrypi.org/documentation/remote-access/ssh/
I hope this helps.
It seems that my answer was to use the Remote Development pack on Visual Studio Code (it's an extension) to ssh into my raspberry pi. It's worked well for me for the past few days, and I highly recommend it. It allowed me to access the entire sd card and access any files I need to, while also giving me an SSH terminal and run the program ON the other machine.
For anyone who does this; set up the whole ssh key thing, to stop having to give the password to the pi so often.
The scp command would also work, I think, but is more complex than what I want to do.
Thank you so much for the answer, JL Peyret!
As my title goes, I tried to look for something can help me to write the script to get CPU usage from another machine which will be running Virtual Machine(VM), yes I want to get the CPU usage of the VM which runs ubuntu and runs as FTP server. The thing is, I'm still trying to write the script in Python which will be run on Raspberry Pi 2.
I found a few solution that needs me to use bash scripting, but I need to compile with my script of sending ICMP request to the other machine. The thing is I need to write the script instead of using another software. Thank you in advance.
You could maybe try it with VNC but that won't give you a script that will just give you a window into the other machine.
I have device connected through serial port to PC. Using c-kermit I can send commands to device and read output. I can also send files using kermit protocol.
In python we have pretty nice library - pySerial. I can use it to send/receive data from device. But is there some nice solution to send files using kermit protocol?
You should be able to do it via the subprocess module. The following assumes that you can send commands to your remote machine and parse out the results already. :-)
I don't have anything to test this on at the moment, so I'm going to be pretty general.
Roughly:
use pyserial to connect to the remote system through the serial port.
run the kermit client on the remote system using switches that will send the file or files you wish to transfer over the remote systems serial port (the serial line you are using.)
disconnect your pyserial instance
start your kermit client with subprocess and accept the files.
reconnect your pyserial instance and clean everything up.
I'm willing to bet this isn't much help, but when I actually did this a few years ago (using os.system, rather than subprocess on a hideous, hideous SuperDOS system) it took me a while to get my fat head around the fact that I had to start a kermit client remotely to send the file to my client!
If I have some time this week I'll break out one of my old geode boards and see if I can post some actual working code.