Home > Net >  I can't do multiple os.system() commands. What am I missing?
I can't do multiple os.system() commands. What am I missing?

Time:07-23

def separateSegments():
    sound_file = pydub.AudioSegment.from_wav("SSTV-Complete-Transmission.wav")
    sound_file_Value = np.array(sound_file.get_array_of_samples())
    # milliseconds in the sound track
    # * 4.88
    ranges = [(0,1805600),(1805600,3625800),(3625800,5494800),(5494800,7300400),(7300400,9106000)]

    #print(str(ranges))

    for x, y in ranges:
        new_file=sound_file_Value[x : y]
        song = pydub.AudioSegment(new_file.tobytes(), frame_rate=sound_file.frame_rate,sample_width=sound_file.sample_width,channels=1)
        song.export("AMEA_Transmission_"   str(x)   "-"   str(y)  ".wav", format="wav")

def processSegments():
    os.system('''cmd /k "sstv -d AMEA_Transmission_0-1805600.wav -o AMEA_Data_Result_0-1805600.png"''')
    jeff = 1
    os.system('''cmd /k "sstv -d AMEA_Transmission_1805600-3625800.wav -o AMEA_Data_Result_1805600-3625800.png"''')

I'm trying to run multiple os.system commands that uses a command prompt command from https://github.com/colaclanth/sstv. For whatever reason, it only runs the first and ignores the second. Is there a way for it to run multiple commands?

CodePudding user response:

cmd /k ... means "run the following command, then remain open". You're running the first os.system call, but since cmd does not terminate, the call never returns, and the program doesn't advance to the next line.

You probably want the /c option instead of /k. That means "run the following command, then terminate".

  • Related