Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Calling internal subroutine from a form submit

by GhodMode (Pilgrim)
on Feb 04, 2006 at 11:09 UTC ( [id://527930]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Calling internal subroutine from a form submit
in thread Calling internal subroutine from a form submit

This is why ikegami was right. It's not clear exactly what you need.

Please post some of your code, identify the code that creates the form, what you want to happen when the form is submitted, and what it's currently doing.

--
-- GhodMode

Replies are listed 'Best First'.
Re^4: Calling internal subroutine from a form submit
by Anonymous Monk on Feb 17, 2009 at 21:28 UTC
    First of all, i'm not the original poster but with the same problem. I'm trying to wrote a small script what does next things: Logs into router over telnet (that part works). Send command to the router and get the necessary date (also works). When i need some extra features to configure in router then a press a certain button, subroutine associated with the button does what it supposed to do and the that's basically it. What i'm trying to do is: Add a Button to the page and this button calls first subroutine. My first sub is sub telnet { logging into router only!}; When i press the button it should call sub called &telnet(); and after successful login it should call another sub what i define and all that should be working on the same page. Without sub pages on my site. Example part of the script that's working fine:
    #!/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
    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:
    @lines = $t->print ("turn off dhcp server"); #for example ($output) = $t->waitfor('/=>$/i'); #waits prompt print $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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://527930]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-03-28 10:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found