Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

[Help]Build a tool/application using Perl

by tctoa (Novice)
on Oct 10, 2019 at 07:24 UTC ( #11107283=perlquestion: print w/replies, xml ) Need Help??

tctoa has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I am a newbie in scripting Perl program. Currently, I have a project that build an application using Perl but I don't have much experiences. So, could you all here please help me on this. My tool/application: Can ssh to a server then issuing commands to get log files and verify them. Example: - ssh to a server address: root@192.168.1.10 , pass: 123456 - issue "date" - get outputs and push them into a variable @tmp. outputs like "Thu Oct 10 02:16:39 CDT 2019" - then i will have a logic to verify them. For now, I tried to find some guides on the Internet, but still confusing... - Using which function to connect to a server, issuing commands and get output? - How to build an application? Also, please help to show me some links or video related. Thank you very much!

  • Comment on [Help]Build a tool/application using Perl

Replies are listed 'Best First'.
Re: [Help]Build a tool/application using Perl
by daxim (Curate) on Oct 10, 2019 at 08:10 UTC
    ssh to a server then issuing commands [] issue "date" - get outputs and push them into a variable @tmp
    Net::SSH::Any seems easiest to me.
    #!/usr/bin/env perl use Net::SSH::Any qw(); my $ssh = Net::SSH::Any->new('192.168.1.10', user => 'root', password +=> '123456'); my @tmp = $ssh->capture('date');
    How to build an application?
    Perhaps Module::Build::Tiny? You need to explain what you want to achieve because "build" can mean different things.

    Simple Perl programs do not require a building step, they can be run as-is.

      Thank you daxim,

      Look like this does not work.

      use Net::SSH::Any qw(); my $ssh = Net::SSH::Any->new( '172.20.251.20', user => 'root', password => 'r3 +v3nue' ); my @tmp = $ssh->capture('ls -lrt'); print " @tmp";

      Output:

       Use of uninitialized value $tmp[0] in join or string at test.pl line 7.

      For the application, please be explained again. I try to give an simple example to easier: - Using Perl to have a script to detect an even number from a number input from keyboar - Create an application base on this script. This can be installed on Windowns. Then, when I wannna find I only need to run the app instead of executing perl "script.pl" I am sorry, I cannot use exactly works to describe.

        I only need to run the app instead of executing perl "script.pl"
        That's called "compile to a standalone executable". See pp or staticperl or perlcc.

        It's easier to just associate the .pl file extension, so when you attempt to run a .pl file (for example by double-clicking in a file manager), it executes Perl automatically. When you use the Strawberry Perl installer, it does that association for you already.

        Consider adding error handling, as documented in Net::SSH::Any:

        my @tmp = $ssh->capture('ls -lrt'); $ssh->error and die "'ls -lrt' failed: " . $ssh->error;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11107283]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2019-10-14 17:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?