Running a multiline shell command
bonnmike at gmail.com
Sat Dec 10 08:29:29 EST 2011
Could also go the open process route.
put "telnet youripdaddress" into tProcess
open process tProcess for update
-- not real code, just quicky pseudo
read from the process until you get the username prompt
write theusername & return to process tProcess
read from process until yuo get the username prompt
write thepassword & return to process tProcess
read till you see a prompt
write "the command you need here" & return to process tProcess
read from process to get the info you need.
There is a very simple interactive shell stack that I posted here somewhere
(was based on windows) but if you change it to run your telnet instead, you
can go through line by line entering the commands yourself (as you did from
a terminal) and see what responses you are looking for so that you can more
easily set up the final script. It will display the promps you need so you
know what you're looking for before each "send"
Another option would be to figure out timings and just "wait for..."
instead of doing a read to see if its time to enter username or password.
Found my link to the interactiveshell stack. Should be easy to find the
place to change "cmd" to your telnet command.
As I said its set up for windows at the moment so will choke on open.
(opens the process when stack opens) so might turn messages off before
opening so you can tweak it first.
On Sat, Dec 10, 2011 at 5:53 AM, Bernard Devlin <bdrunrev at gmail.com> wrote:
> Could it be an issue with the "return" character? As you know, they are
> different on each platform. You could try variations between ascii 10 and
> If you have it working as a script on your file system, you could try
> putting that script into a custom property (get hold of it using a binfile
> URL schema). If that can be successfully passed to telnet and you get the
> response you expect, then you know that the problem lies elsewhere. Whilst
> tracking down the problem, I'd get it working with the correct username and
> password in the script on the filesystem, then with those in place move
> that script into the stack as a binary object, and worry about substituting
> them later for deployment.
> On Sat, Dec 10, 2011 at 2:50 AM, Bob Sneidar <bobs at twft.com> wrote:
> > This has been discussed before, but I am trying to run multiple lines of
> > shell commands using the shell() function. It looked like it worked at
> > first, only the telnet session dumped me before I could get any
> > out of the switch. Now it looks like I am not even talking to the shell
> > anymore. The shell script looks like this:
> > script "/users/shared/macaddresses.txt"
> > telnet 172.16.0.121
> > theUser
> > thePassword
> > print "show mac-address"
> > exit
> > exit
> > y
> > n
> > script off
> > I have this in a stack property, and put it into a variable. I replace
> > theUser and thePassword with the actual credentials before running
> > The result is empty. I have executed the above commands line by line in a
> > terminal and I do end up with a file with the output of the shell window
> > neat as you please. But when I try to execute within Livecode using the
> > shell() function I get squadouche.
> > The goal is to get the mac address table from a Procurve managed switch.
> > Any ideas?
> > Bob
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
More information about the Use-livecode