Re: cannot call a process via telnet
I just want you to know that the solution of my problem was to change the prompt! When I call the remote bash via telnet to change the directory it expacted the old prompt which was guilty while login: Prompt = '/\[datagate\]\/KOMM\/datagate But after changing the directory the prompt was modified. So the solution to call a simple ls is: @ra = $t-cmd ( String = 'ls', Prompt = '/\[datagate\]\/KOMM\/datagate\/STALP\/PERL\/BERT /'); print @ra; And to call a routine is: $rs = $t-cmd ( String = 'komm-test.pl', Prompt = '/\[datagate\]\/KOMM\/datagate\/STALP\/PERL\/BERT /'); Hope this helps anybody who'll encounter the same problem ... MIND THE PROMPT ;-) Thanks all for help Gruss Christian -- Christian Stalp Institut für Medizinische Biometrie, Epidemiologie und Informatik (IMBEI) Obere Zahlbacher Straße 69 55131 Mainz Tel.: 06131/ 17-6852 E-Mail: [EMAIL PROTECTED] Internet: www.imbei.de -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
cannot call a process via telnet
Hello together, I have certain problem with the Net::Telnet () -package. I try to call a program on a remote server over the telnet. ( I cannot use SSH in this case! ) my $command = cd /home/chris/servlist $t = new Net::Telnet (Timeout = 15,Prompt = '/\[datagate\]\/KOMM\/datagate/') or die cannot call telnet!\n; $t-open (komm) or die cannot establish a connection!\n; $rueck = $t-login ($username, $passwd) or die login failed!\n; ... so far it works. But now I try this: @ra = $t-print ( $command_1 ) or die cannot change dir !\n; $rs = $t-print ( ./komm-test.pl ) or die cannot start script!\n; And this doesn't work. I neither crashes down nor gives me a error-message! The return value $rs is 1 $t-close (); What did I wrong? Gruss Christian P.S by the way, I can see that the script doesn't start because komm-test.pl creates a file if it starts! -- Christian Stalp Institut für Medizinische Biometrie, Epidemiologie und Informatik (IMBEI) Obere Zahlbacher Straße 69 55131 Mainz Tel.: 06131/ 17-6852 E-Mail: [EMAIL PROTECTED] Internet: www.imbei.de -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: cannot call a process via telnet
Hello together, I have certain problem with the Net::Telnet () -package. I try to call a program on a remote server over the telnet. ( I cannot use SSH in this case! ) What you have shown won't compile. Are you using 'strict' and 'warnings'? If not you need to be. my $command = cd /home/chris/servlist No closing quote or semi-colon in the above. $t = new Net::Telnet (Timeout = 15,Prompt = '/\[datagate\]\/KOMM\/datagate/') or die cannot call telnet!\n; You aren't declaring the scope of $t. $t-open (komm) or die cannot establish a connection!\n; $rueck = $t-login ($username, $passwd) or die login failed!\n; ... so far it works. But now I try this: @ra = $t-print ( $command_1 ) or die cannot change dir !\n; You aren't declaring @ra. You appear to try to be running $command_1 instead of $command. Turn on 'strict' and 'warnings'. $rs = $t-print ( ./komm-test.pl ) or die cannot start script!\n; And this doesn't work. I neither crashes down nor gives me a error-message! The return value $rs is 1 $t-close (); What did I wrong? Gruss Christian P.S by the way, I can see that the script doesn't start because komm-test.pl creates a file if it starts! Not really a good way to tell. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: cannot call a process via telnet
What you have shown won't compile. Are you using 'strict' and 'warnings'? If not you need to be. Its not the whole file. I paste some parts of the script into the mail ,renamed the variables in english ... but I also doesn't use strict. Maybe this gives me a hint of whats going wrong. Gruss Christian -- Christian Stalp Institut für Medizinische Biometrie, Epidemiologie und Informatik (IMBEI) Obere Zahlbacher Straße 69 55131 Mainz Tel.: 06131/ 17-6852 E-Mail: [EMAIL PROTECTED] Internet: www.imbei.de -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: cannot call a process via telnet
As I expact, I just fixed the scope errors but the problem remains. This is it: sub telnet_access { my $username = $main::username; my $passwd = $main::passwd; my $command_1 = cd /home/chris/servlist/; my @ra; my $rs; my $t; $t = new Net::Telnet (Timeout = 15,Prompt = '/\[datagate\]\/KOMM\/datagate /') or die cannot call telnet!\n; $t-open (komm) or die cannot establish a connection!\n; $rs = $t-login ($username, $passwd) or die login failed\n; @ra = $t-print ( $command_1 ) or die cannot change dir!\n; $rs = $t-print ( ./komm-test.pl ) or die cannot start script!\n; print $rs\n; $t-close (); } It runs without any errors but also without purpose, because it doesn't start the script on the remote host. :-\ Gruss Christian -- Christian Stalp Institut für Medizinische Biometrie, Epidemiologie und Informatik (IMBEI) Obere Zahlbacher Straße 69 55131 Mainz Tel.: 06131/ 17-6852 E-Mail: [EMAIL PROTECTED] Internet: www.imbei.de -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: cannot call a process via telnet
What you have shown won't compile. Are you using 'strict' and 'warnings'? If not you need to be. Its not the whole file. I paste some parts of the script into the mail ,renamed the variables in english ... but I also doesn't use strict. Maybe this gives me a hint of whats going wrong. Gruss Christian It should help, if it doesn't lead you to the error then paste the actual code, or at least some of it. If you paste code similar but not the same we can't tell whether the problems from your re-entry are the reason for failure or something else. You also don't really need to change variable names to english, variables are variables, and that is one of the beautiful things about Perl, because of the sigils, the context, and the other punctuation we can grok the meaning without actually knowing what the variable names mean. We may not all speak German here, but we definitely all speak Perl :-) http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: cannot call a process via telnet
As I expact, I just fixed the scope errors but the problem remains. This is it: sub telnet_access { my $username = $main::username; my $passwd = $main::passwd; Generally we want our subroutines to be passed arguments and return values. The above has avoided the scoping symptom but not really fixed the encapsulation problem. You should pass the username and password to the sub rather than calling from the sub into the global scope. my $command_1 = cd /home/chris/servlist/; my @ra; my $rs; my $t; Its considered better style to declare your variables at first usage rather than as a list at the top. This helps to get proper scoping and to avoid spelling errors, etc. $t = new Net::Telnet (Timeout = 15,Prompt = '/\[datagate\]\/KOMM\/datagate /') or die cannot call telnet!\n; $t-open (komm) or die cannot establish a connection!\n; $rs = $t-login ($username, $passwd) or die login failed\n; @ra = $t-print ( $command_1 ) or die cannot change dir!\n; $rs = $t-print ( ./komm-test.pl ) or die cannot start script!\n; The Cprint method is not used for running commands but is instead used for sending input to the process on the other side. You should be using the Ccmd method to issue a command. Check back to the Net::Telnet docs, specifically for the two methods. If 'komm-test.pl' is expecting input from STDIN for instance you would use Cprint otherwise you aren't likely to need it. perldoc Net::Telnet for the documentation. print $rs\n; $t-close (); } It runs without any errors but also without purpose, because it doesn't start the script on the remote host. :-\ Gruss Christian http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: cannot call a process via telnet
Okay now I tryed instead of: $rs = $t-print ( ./komm-test.pl ) or die cannot execute !\n; this: $rueck_s = $t-cmd ( ./komm-test.pl ) or die Kann kein Script starten!\n; and get this message: command timed-out at Refdb.pm line 94 And this is absolutly normal because the script which is called takes a lot of time to execute. But to call it with an '' dosn't fix it neighter What can I do in this case? Thank you very much... Gruss Christian -- Christian Stalp Institut für Medizinische Biometrie, Epidemiologie und Informatik (IMBEI) Obere Zahlbacher Straße 69 55131 Mainz Tel.: 06131/ 17-6852 E-Mail: [EMAIL PROTECTED] Internet: www.imbei.de -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: cannot call a process via telnet
Please group reply so others can help and be helped, and to prevent getting (accidentally) ignored. Okay now I tryed instead of: $rs = $t-print ( ./komm-test.pl ) or die cannot execute !\n; this: $rueck_s = $t-cmd ( ./komm-test.pl ) or die Kann kein Script starten!\n; and get this message: command timed-out at Refdb.pm line 94 And this is absolutly normal because the script which is called takes a lot of time to execute. But to call it with an '' dosn't fix it neighter What can I do in this case? It appears from the docs that the Ccmd method can take a timeout as well. I suspect adding the '' will cause problems because the shell will return control to Net::Telnet and there will be no way to communicate with the process. Note that when you switch to include other arguments with Ccmd it appears you need to pass the command with the 'String' key. Thank you very much... Gruss Christian You need to read the docs thoroughly before asking questions http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: cannot call a process via telnet
It appears from the docs that the Ccmd method can take a timeout as well. I suspect adding the '' will cause problems because the shell will return control to Net::Telnet and there will be no way to communicate with the process. Note that when you switch to include other arguments with Ccmd it appears you need to pass the command with the 'String' key. Sure but this doesn't make any change if I call the cmd with a prepared string or a directly into the brackets. I was at this point a few hours before. Calling a process with the cmd- method. Then I found the print - method in the docs. But both have the same problem: sending a command over the telnet without waiting for the answer. And I don't want to change the timeout because the script has more functions than to wait for another process exit. The docs doesn't give any solution how to make this! Its no problem to call a process manualy over the telnet with a '' at least our servers! Gruss Christian -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: cannot call a process via telnet
It appears from the docs that the Ccmd method can take a timeout as well. I suspect adding the '' will cause problems because the shell will return control to Net::Telnet and there will be no way to communicate with the process. Note that when you switch to include other arguments with Ccmd it appears you need to pass the command with the 'String' key. Sure but this doesn't make any change if I call the cmd with a prepared string or a directly into the brackets. I was at this point a few hours before. Calling a process with the cmd- method. Then I found the print - method in the docs. But both have the same problem: sending a command over the telnet without waiting for the answer. And I don't want to change the timeout because the script has more functions than to wait for another process exit. The docs doesn't give any solution how to make this! Its no problem to call a process manualy over the telnet with a '' at least our servers! Gruss Christian huh, one might think that would have been helpful to mention up front. Now that we have come full circle I will point you once again back to the docs, and this time specifically the Cwaitfor method and the list of 3-4 examples at the bottom of the docs that talk about how to interact with a program, specifically the ssh example and the passwd example. This should allow you to turn off the timeout, or at least set it to something arbitrarily high. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: cannot call a process via telnet
- Original Message - From: Christian Stalp [EMAIL PROTECTED] Date: Tuesday, October 12, 2004 12:18 pm Subject: Re: cannot call a process via telnet It appears from the docs that the Ccmd method can take a timeout as well. I suspect adding the '' will cause problems because the shell will return control to Net::Telnet and there will be no way to communicate with the process. Note that when you switch to include other arguments with Ccmd it appears you need to pass the command with the 'String' key. Sure but this doesn't make any change if I call the cmd with a prepared string or a directly into the brackets. I was at this point a few hours before. Calling a process with the cmd- method. Then I found the print - method in the docs. But both have the same problem: sending a command over the telnet without waiting for the answer. And I don't want to change the timeout because the script has more functions than to wait for another process exit. The docs doesn't give any solution how to make this! Its no problem to call a process manualy over the telnet with a '' at least our servers! Gruss, Perhaps what you are looking for is net-rexec ?? Gruss Christian -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response