saurabh agarwal
saurabh agarwal

Reputation: 2184

Run commands in command prompt using python script

I have a embedded board that I access from board's serial port. I run/type some command in this board. I want to automate this task. I want to write a script that executes and run all the command by itself. This script should wait for previous command to finish.

I know a software "SecureCRT" can do it but that is not free.

EDIT: My embedded board is like a remote computer. So, using python command I am first logging in my board and then trying to run some commands.

My Code looks like this.

import os
import time 

os.system("sudo minicom usb");
time.sleep(1);
#os.system("<some_command_on_remote_computer>");
os.system("ls -a");
time.sleep(1);

minicom usb shows the serial port output of my embedded board. All debug prints of my port are coming on this port. So, by using "sudo minicom usb" command, I am able to log in my embedded board but after that I can't run "ls -a" command on my embedded board.

I came acroos paramiko package but works on ssh, I can't figure out how to use it for my problem.

Upvotes: 1

Views: 925

Answers (1)

TessellatingHeckler
TessellatingHeckler

Reputation: 29033

Forget trying to control a command prompt terminal program, use the PySerial module to open the serial port and send data directly.

Upvotes: 2

Related Questions