How can I open a remote ssh session with perl

2010-08-24 Thread S Pratap Singh
Hello ,

I want to open a remote ssh session using the perl script , I am able to
login to  the server using the simple script and i am also able to execute
few commands which is defined in the script on the server.

I am writing a script which takes the user name , password and hostname from
the database and login to the server .

I am only able to login to the server and my script logs out and only I can
run few command if I provide those command in my script else I am not able
to run those command after logging in.

I need to run those command once I have logged in using my script and I want
to track down all the commands being executed in a particular session.

I know how to run command on remote shell using script , but I want to open
remote shell using perl and want to run the command manually and terminate
the session when I am done as we normally do with shell .

Any help or guidance will be highly appreciated.


-- 
Regards,
Pratap Singh


Re: How can I open a remote ssh session with perl

2010-08-24 Thread Peter Scott
On Tue, 24 Aug 2010 14:25:01 +0530, S Pratap Singh wrote:
 
 I know how to run command on remote shell using script , but I want to
 open remote shell using perl and want to run the command manually and
 terminate the session when I am done as we normally do with shell .

CPAN: Net::SSH::Perl .

-- 
Peter Scott
http://www.perlmedic.com/ http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274
http://www.oreillyschool.com/courses/perl1/

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Image magick

2010-08-24 Thread Chaitanya Yanamadala
Hai
i am using the image magick to convert an image from 72 dpi to 300 dpi. with
the corresponding image height and width.
but now i need to resize this image to the corresponding height and width
which are existing at 72 dpi.
when i do that it is not creating the image with the exact values i gave..
how do i do with exact values.
or else can i keep the image with the fixed height and let image magick take
the proportionate width for me.
Can any one help me on this..
this is my code..

 my $file = shift;
 my $folder   = ;
 my $filename = $folder . $file . .jpg;
 $image = Image::Magick-new;

 if ( -e $filename ) {
 my $jpgfile  = $folder . $file . _new.jpg;
 my $tjpgfile = $folder . $file . _t.jpg;
 my $err  = 0;
 print $filename. \n;
 my $image = Image::Magick-new;
 eval { my $ImgRead = $image-Read($filename); };
 if ($@) {
 $err = 1;
 print cannot read input\n;
 return ( , , $err );
 }
 my $width = $image-[0]-Get('width');
 my $height= $image-[0]-Get('height');
 my $xy= $image-[0]-Get('density');
 my @xyz   = split( x, $xy );
 my $density   = 300;
 my $imgwidth  = ( $width / $xyz[0] ) * $density;
 my $imgheight = ( $height / $xyz[0] ) * $density;
 #print XY==  . $xyz[0] . \n;
 $log_data .= XYZ array == @xyz\n;
 $log_data .= Width== .$width.\n;
 $log_data .= Height== .$height.\n;
 eval {
 # if($xyz[0] ne '300'){
 # system( convert $filename -resize 
 # . ceil($imgwidth) . x
 # . ceil($imgheight)
 # . ! -density $density -quality 80 $jpgfile );
 # }
 # system(convert $filename -resize 150x130 $tjpgfile);
 $image-[0]-Thumbnail(width=$imgwidth,height=$imgheight);
 $image-[0]-Set(density=300);
 $image-[0]-Set(units=PixelsPerInch);
 $image-[0]-Resize($height);
 #$image-[0]-Thumbnail(width=$width,height=$height);
 $image-[0]-Set(quality=100);
 $image-[0]-Set(units=PixelsPerInch);
 $image-Write(filename=$jpgfile);

 $image-[0]-Thumbnail(width='150',height='130');
 $image-[0]-Set(density=300);
 $image-[0]-Set(units=PixelsPerInch);
 $image-Write(filename=$tjpgfile);
 };
 if ($@) {
 $err = 1;
 print cannot convert input\n;
 return ( , , $err );
 }

 #unlink($filename);
 return ( $jpgfile, $tjpgfile, $err );
 }
 else {
 $log_data .= $filename .  does not exist\n;
 }


Chaitanya


Re: How can I open a remote ssh session with perl

2010-08-24 Thread Brian Fraser
On Tue, Aug 24, 2010 at 11:08 AM, Peter Scott pe...@psdt.com wrote:


 CPAN: Net::SSH::Perl .

I had a similar issue not too long ago; Spent a couple of days attempting to
get Net::SSH::Perl to compile properly, gave up, went to CPAN, found
[Net::SSH::Expect][0]; So far so good, so here's a recommendation.

[0]
http://search.cpan.org/~bnegrao/Net-SSH-Expect-1.09/lib/Net/SSH/Expect.podhttp://search.cpan.org/%7Ebnegrao/Net-SSH-Expect-1.09/lib/Net/SSH/Expect.pod