in reply to Re^3: Calling internal subroutine from a form submit
in thread Calling internal subroutine from a form submit
This is all in one script to show you working part. I know how to make a sub but How to call it with the button. How to call several sub one after one just cliking the button. Second sub contains something like that:#!/usr/bin/perl -w print "Content-type: text/html\r\n\r\n"; use Net::Telnet (); use CGI qw (:standard);; my $user = 'username'; my $pass = 'password'; my $host = "192.168.1.254"; $t = new Net::Telnet (Timeout => 1, Prompt => '/\$ $/i'); $t->open($host); $t->waitfor('/: $/i'); $t->print($user); $t->waitfor('/ : $/i'); $t->print($pass); $t->waitfor('/>$/i'); @lines = $t->print ("system settime"); # it takes router uptime info ($output) = $t->waitfor('/=>$/i'); print "<pre>"; #for nice output print $output; $t->print("exit"); print "</pre>"; #for nice output
"turn off dhcp server" - whatever command i will wrote there. It's not a good idea to call all subroutines at once, one bye one. It's not necessary, could make something worse etc. To make this "page" more compact i would like to call those subs in the script itself with a button. Any hints, examples appreciated!@lines = $t->print ("turn off dhcp server"); #for example ($output) = $t->waitfor('/=>$/i'); #waits prompt print $output;
|
|---|