0
Thanks

A few words of thanks would be greatly appreciated.

Launch and run commands from shell script



Issue


I have a requirement to launch a busybox (Qemu) shell and needs to pass the commands to get the result. How I can achieve this.

For example:

I have the running Qemu and I am telnetting to get shell.

Open the terminal and do a
"telnet 192.168.100.3"
this command will takes to a busybox shell now type "ps" command this will gives all the running process inside the Qemu.

Now i want to automate the above steps in a shell scripting something like
===============
#! /bin/sh 
telnet 192.168.100.3 
ps 

===============

Solution


The code below works for me:

#! /bin/bash 

( 
ps 
sleep 1 
) | telnet 192.168.100.3 

exit

Note


Thanks to Hari for this tip on the forum.
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « Launch and run commands from shell script », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

0 Comments