I want to use python achieve following process:
[zz@bts01 ~]$ cd /opt/cdma-msc/
[zz@bts01 cdma-msc]$ ./sccli
SoftCore for CDMA CLI (c) Quortus 2010
RAN> show system
System Configuration
Software version: V1.31
System name: RAN
System location:
Shutdown code:
Emergency call dest:
Current date/time: Tue Feb 27 14:27:41 2018
System uptime: 20h 33m
Auto-provisioning: Enabled
RAN> exit
Bye.
[zz@bts01 cdma-msc]$
Please see above, I want to use python to call this /opt/cdma-msc/rancli process, which will open a secondary shell, and I want to capture the output of command "show license" in that shell. How can I achieve this in python? I tried with subprocess Popen, and was able to call the shell, but cannot enter anything into it. Anyone have some thought?
ran = subprocess.Popen(['/opt/cdma-msc/sccli'], shell = True, stdout = subprocess.PIPE)
hnb = subprocess.Popen(['show system'],stdin=ran.stdout )
above is the python module/command I tried, apparently the second line didn't take the output from first, casue it is calling another shell.