Package: cmdbashinteractive
Interact with subprocesses running both bash.exe (CygWin) and cmd.exe without terminating them.pip install cmdbashinteractiveArgs:print_stdout(bool,optional):Whethertoprintstdoutfromthesubprocess(defaultisTrue).print_stderr(bool,optional):Whethertoprintstderrfromthesubprocess(defaultisTrue).limit_stdout(int,optional):Maximumnumberoflinestokeepinstdouthistory(defaultisNone).limit_stderr(int,optional):Maximumnumberoflinestokeepinstderrhistory(defaultisNone).limit_stdin(int,optional):Maximumnumberoflinestokeepinstdinhistory(defaultisNone).convert_to_83(bool,optional):Whethertoconvertfilepathstoshort(8.3)format(defaultisTrue).exitcommand(str,optional):Thecommandtosignalthesubprocesstoexit(defaultis"▓▓▓▓▓▓▓▓▓▓▓").newline(str,optional):Thenewlinecharactertouse(defaultis"\n").getcomspec(str,optional):Thecommandtogettheshellexecutable(defaultis"bash.exe").wait_to_complete(float,optional):Thetimetowaitforsubprocesscompletion(defaultis0.1seconds).**kwargs:Additionalkeywordargumentsforsubprocess.Popen.importosfromcmdbashinteractiveimportBashInteractive,CmdInteractiveCREATE_NEW_PROCESS_GROUP=0x00000200DETACHED_PROCESS=0x00000008sh=BashInteractive(print_stdout=True,print_stderr=True,limit_stdout=None,limit_stderr=None,limit_stdin=None,convert_to_83=True,exitcommand="▓▓▓▓▓▓▓▓▓▓▓",newline="\n",getcomspec=r"C:\cygwin\bin\bash.exe",wait_to_complete=0.1,shell=False,# **kwargscreationflags=DETACHED_PROCESS|CREATE_NEW_PROCESS_GROUP,# **kwargsbufsize=0,# **kwargsenv=os.environ.copy(),# **kwargs)stdo00,stde00=sh("ls")sh.install("tar")stdo01,stde01=sh("ping google.com | grep bytes")stdo02,stde02=sh(r"cat C:\yolov5max - Copy\2023_08_17.ini")# automatically converted to 8.3 and afterwards to cygwin  when convert_to_83 is TrueArgs:print_stdout(bool,optional):Whethertoprintstdoutfromthesubprocess(defaultisTrue).print_stderr(bool,optional):Whethertoprintstderrfromthesubprocess(defaultisTrue).limit_stdout(int,optional):Maximumnumberoflinestokeepinstdouthistory(defaultisNone).limit_stderr(int,optional):Maximumnumberoflinestokeepinstderrhistory(defaultisNone).limit_stdin(int,optional):Maximumnumberoflinestokeepinstdinhistory(defaultisNone).convert_to_83(bool,optional):Whethertoconvertfilepathstoshort(8.3)format(defaultisTrue).exitcommand(str,optional):Thecommandtosignalthesubprocesstoexit(defaultis"▓▓▓▓▓▓▓▓▓▓▓").getcomspec(str,optional):Thecommandtogettheshellexecutable(defaultisNone).newline(str,optional):Thenewlinecharactertouse(defaultis"\r\n").wait_to_complete(float,optional):Theintervaltocheckforsubprocesscompletion(defaultis0.1seconds).**kwargs:Additionalkeywordargumentsforsubprocess.Popen.cmd=CmdInteractive(print_stdout=True,print_stderr=True,limit_stdout=10,limit_stderr=10,limit_stdin=10,convert_to_83=True,exitcommand="▓▓▓▓▓▓▓▓▓▓▓",wait_to_complete=0.1,shell=False,# **kwargscreationflags=DETACHED_PROCESS|CREATE_NEW_PROCESS_GROUP,# **kwargsbufsize=0,# **kwargsenv=os.environ.copy(),# **kwargsgetcomspec=None,newline="\r\n",)#strfi=sh(r"strings C:\yolov5max - Copy\2023_08_17.ini")# automatically converted to 8.3 when convert_to_83 is Truestdo0,stde0=cmd(f"ping google.com",wait_to_complete=0.1)stdo1,stde1=cmd(f"dir",wait_to_complete=0.1)stdo2,stde2=cmd(f"whoami.exe",wait_to_complete=0.1)stdo3,stde3=cmd(f"ping google.com",wait_to_complete=0)# non blocking, not recommended - might mess up stdout,stderrstdo4,stde4=cmd(f"dir",wait_to_complete=0)# non blocking, not recommended - might mess up stdout,stderrstdo5,stde5=cmd(f"whoami.exe",wait_to_complete=0)# non blocking, not recommended - might mess up stdout,stderr