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

I have written script in windows. It is running fine. But If I try to run in linux it is not giving output and also it is not throughing any error.

use Net::SSH::Any; use Config::IniFiles; # Check for valid number of arguments if (!defined $ARGV[0] && !defined $ARGV[1]) { die("Usage: export_ddts.pl projectname tmpl_path \n"); }; my $project = $ARGV[0]; my $tmpl = $ARGV[1]; ) #command to fetch records under particular class or project my $cmd="findbug -k $project |dumpbug -fnt $tmpl"; #Connecting to Config Files my $cfg = Config::IniFiles->new( -file => "configfile.ini" ); #fetching Remote connection credentials from .ini file my $ssh_url =$cfg->val( 'REMOTE_CREDENTIALS', 'HOST' ); my $ssh_user =$cfg->val( 'REMOTE_CREDENTIALS', 'USERNAME' ); my $ssh_pwd =$cfg->val( 'REMOTE_CREDENTIALS', 'PASSWORD' ); #Connecting to server and Fetching details my $ssh = Net::SSH::Any->new($ssh_url, user => $ssh_user, password => +$ssh_pwd); print "Connecting to Server........."; print "$cmd"; $ssh->system($cmd); #end of File

Is there any problem with CPAN modules which I'm using? Or Are CPAN modules differ from windows to Linux? please help me

Replies are listed 'Best First'.
Re: Query on Running perl Script in linux
by salva (Canon) on Feb 24, 2014 at 14:52 UTC
    Check for errors using $ssh->error after every call.
Re: Query on Running perl Script in linux
by hazylife (Monk) on Feb 24, 2014 at 13:19 UTC

    It is most likely that your prints are getting buffered. To further debug this, you'll need to turn off STDOUT buffering by putting

    $| = 1;

    somewhere near the top of your script. You could also add line breaks where appropriate, e.g.:

    print "Connecting to Server.........\n"; print "$cmd\n";
Re: Query on Running perl Script in linux
by Discipulus (Canon) on Feb 24, 2014 at 13:25 UTC
    maybe some module is not supported in your platform?

    PS. surprisingly in the module docs is said "Post questions related to how to use the module in Perlmonks http://perlmoks.org/..."

    Hth
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      'PS. surprisingly in the module docs is said "Post questions related to how to use the module in Perlmonks http://perlmoks.org/..."'

      Probably because the module author, salva, is here nearly every day.

      To salva: Just pointing out the typo (s{moks}{monks}) in that POD link. :-)

      -- Ken

Re: Query on Running perl Script in linux
by dbuckhal (Chaplain) on Feb 25, 2014 at 04:45 UTC

    If that is your exact code you are trying to use, then it is missing the "shebang!" line. In Windows, you probably have file association doing the work for you in relating your Perl script to whatever Perl you have installed (Strawberry, Activestate,etc...).

    But, on the Unix/Linux platform, you can add the program to execute your script on the first line:

    #!/usr/bin/perl

    Otherwise, you can also run your script by calling "perl", followed by your script name as the argument:

    $ perl my_script.pl

    On Unix/Linux, just type "which perl" at the prompt and that will tell you the path to use when you add the "shebang!" line at the top of your code

    So, your first few lines of you code would look like this:

    #!/usr/bin/perl use Net::SSH::Any; use Config::IniFiles; # Check for valid number of arguments if (!defined $ARGV[0] && !defined $ARGV[1]) { die("Usage: export_ddts.pl projectname tmpl_path \n"); }; . . .

    The only thing left would to just make it executable:

    chmod +x myScript.pl

    ...and you will be able to run it by just typing its name at the prompt.

    $ ./myScript

    NOTE: this just assumes that your posted code is exactly what you are trying to execute and I just noticed the "shebang!" missing. If I'm way off target, my bad. :)

      I'm getting this error now  Invalid or bad combination of options ('passphrase', 'key_path') at /srv/data203806/CPAN/localperl/lib/5.18.2/Net/SSH/Any/Backend/Net_OpenSSH.pm line 27. I'm not using system perl I have installed perl in another directory "srv/data203806/CPAN/localperl/lib" One more query. Are CPAN modules dependent on OS platform?
        Are CPAN modules dependent on OS platform?

        Not all CPAN modules work on every OS ... but most are designed to work on most systems.
        Net::SSH::Any is intended to work fine on both linux and windows - so it would be appreciated if you can provide the info that salva needs to sort out the problem.

        Cheers,
        Rob
        Show us your updated code!

        That message means you are passing the constructor options that are incompatile. For instance, the path to a private key and a password.

        It may also be a bug inside Net::SSH::Any but without seeing your code it is hard to tell.

        I'm getting the exact same error. I'm using cygwin. This error happens when using the new method. Here is my code that generates the error. $Fab2SwitchSSH = Net::SSH::Any->new( $fab2_ip, user => $fab2_userid, password => $fab2_password);