ambar686
Posts: 15
Joined: Sun Aug 10, 2014 6:17 am

Run two python scripts one after another

Tue Aug 26, 2014 2:29 pm

Hello everyone,
I have made two python scripts each on the motor control. One program runs the motors in forward direction and another program runs the motor in reverse direction.
Now I want to run two scripts with the delay of 5 secs. I mean, script1.py first and script2.py after script1.py.
Please help me to write the code. I will rotate the motor in forward direction (script1.py) for 5 secs and after that the motors will rotate in reverse direction (script2.py). then again in forward direction and again in reverse. This will continue until I halt the program manually.
Any suggestion is acceptable. :?: :idea: :idea:

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Run two python scripts one after another

Tue Aug 26, 2014 10:34 pm

Why not just create a single Python script that does what you want? Using two separate python scripts seems to be making it more complicated than necessary.

But if that's what you really want :?

Code: Select all

#!/bin/bash
while true; do
  python script1.py
  sleep 5
  python script2.py
  sleep 5
done

ambar686
Posts: 15
Joined: Sun Aug 10, 2014 6:17 am

Re: Run two python scripts one after another

Wed Aug 27, 2014 1:18 am

Hi,
Thank you! I will try this shell script and let you know! :D :) :D

Return to “Beginners”