-1

here is the skeleton script that i am using:

#!/usr/bin/env perl

=head1 NAME

webapp-1 harness - webapp-1 test

=head1 SYNOPSIS

    webapp-1 [OPTION]

    -v, --verbose  use verbose mode
    --help         print this help message

Where OPTION is an integer governing the number of times the script should be run

Examples:

    webapp-1 10 

=head1 DESCRIPTION

This is test harness to verify jira issue WEBAPP-1

=head1 AUTHOR

[email protected]

=cut

use strict;
use warnings;

use Getopt::Long qw(:config auto_help);
use Pod::Usage;

my $count = $ARGV;

main();

sub main {

    # Argument parsing
    my $verbose;
    GetOptions(
        'verbose'  => \$verbose,
    ) or pod2usage(1);
    pod2usage(1)unless @ARGV;

    while ($count) {
    printf "$count \n";
    # Here i want to run a perl script N number of times, with N being the ARGV to this command
    # capture( [0,1,2, $^X, "yourscript.pl", @ARGS );
    $count++;
    }
}

I also cannot use IPC::System since i cannot install it on the host (ubuntu 12.04) i am running it on. What i am trying to do is to develop a perl test harness, which will run perl scripts to run processes, monitor database tables, etc and i can also control the timing of these scripts, based on the results i get from their execution.

one possible solution: for running a script N number of times based on @ARGV

foreach (1..$ARGV[0])
    {
      print "hello \n";
    }
6
  • take a look at: stackoverflow.com/questions/364842/… Commented Jan 8, 2013 at 17:11
  • Please can you clarify what the difficulty is in installing the module? Maybe we can overcome that. Also is IPC::System its exact name? No module of that name comes up when searching MetaCPAN for it. Commented Jan 8, 2013 at 17:14
  • @Smylers its IPC::System::Simple if i use cpanminus, i would have to be root, or have root permissions, to install the module, which i cannot get from sysOPS Commented Jan 8, 2013 at 17:26
  • i think i resolved this by using system($^X, "hello.pl", @ARGV); , since the argument of the PARENT script is being used for the CHILD script. Now just have to figure out how to run it @ARGV number of times Commented Jan 8, 2013 at 17:34
  • 1
    Have you tied a GNU Parallel? Commented Jan 8, 2013 at 17:52

1 Answer 1

1

You don't need root privs to install Cpan modules.

cpanm takes a -l option for installing into a specified directory, such as under ~/perl5/.

Then in your program use the local::lib module to direct perl to where you installed modules. This is as simple as:

use local::lib '~/project/lib';

or, if you pick ~/perl5/ for installing to, simply:

use local::lib;

Both CpanMinus and local::lib can be bootstrap-installed as non-root:

Together these give you the power of Cpan without requiring assistance from the server's sys-admin.

Sign up to request clarification or add additional context in comments.

2 Comments

i have no access to cpanm ( just learned ) and when i try to install locally, i get lib/perl5/5.8.8/CPAN/Config.pm is not writable, error
@kamal You can install cpanm locally with wget -O - http://cpanmin.us | perl - --self-upgrade -l

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.