Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl NET::Telnet

Status
Not open for further replies.

nagashankarp

IS-IT--Management
Dec 8, 2008
3
GB
Greetings to all
I have a requirement of passing a few user-defined parameters through Net::Telnet and these parameters will be used by my UNIX Script, is there a way to do this..


use Net::Telnet ();
$t = new Net::Telnet (Timeout => 10);
$t->open("sever");
$t->login(user, pass);
@lines = $t->cmd("/cc/ac_scr.sh $CL $EA");


In the above examples I want to use $CL and $EA which are on the windows system and needs to be passed to the unix system for the script ac_scr.sh to work.

Cheers
Shankar


 
as long as $CL and $EA conform to *nix stds, it should work fine.
 
What do you mean by "on the windows system"?

If they are in your windows environment, you can access them as
Code:
@lines = $t->cmd("/cc/ac_scr.sh $ENV{CL} $ENV{EA}");

Yours,

fish

["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life was going to be spent in finding mistakes in my own programs.["]
--Maurice Wilkes, 1949
 
When i execute the line
$t->cmd("/cc/ac_scr.sh $ENV{CL} $ENV{EA}");

it uses the env variables that are set in UNIX system.

But if I use this script to run from a Windows system and the parameters are set on windows they are not passed.

Is there a way to do this ?
 
I still don't think I understand :)

Are you sure those variables exists on the windows system?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Yes these varaibles are set on Windows and can be extracted in by perl program.

I have gone a bit further since my last post. I have managed a work around for now by writing a temp file, see below

use IO::File;
use Net::Telnet ();
$ccuser = $ENV { 'CLEARCASE_USER' };
$log = "\\\\server\\cc\\LOGS\\$ccuser.$$";
$cont = "$ccuser";
my $file = new IO::File;
$file->open(">${log}");
$file->write($cont);
$file->close;
$t = new Net::Telnet (Timeout => 10);
$t->open("server");
$t->login(user, pass);
@lines = $t->cmd("/server/cc/ac.sh");
print @lines;

Now with in ac.sh, I use the log file that has the parameters and remove this temp file.

Basically this is a two way procedure, What I was wondering was if this can be done in one step.

I hope I am clear this time :)

Cheers
Shankar
 
You can just do
@lines = $t->cmd("/server/cc/ac.sh $ccuser");

Assuming (<--- read!!!) that ac.sh takes a command line variable like that. It will definitely pass though.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top