-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

skahmed@mmm.com

=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";
    }
Gray
  • 7,050
  • 2
  • 29
  • 52
kamal
  • 9,637
  • 30
  • 101
  • 168
  • take a look at: http://stackoverflow.com/questions/364842/how-do-i-run-a-perl-script-from-within-a-perl-script?rq=1 – Paul Jan 08 '13 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](https://metacpan.org/search?q=IPC%3A%3ASystem). – Smylers Jan 08 '13 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 – kamal Jan 08 '13 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 – kamal Jan 08 '13 at 17:34
  • 1
    Have you tied a [GNU Parallel](http://www.gnu.org/software/parallel/)? – alex Jan 08 '13 at 17:52
  • @user1883592 Thanks for introducing me to GNU Parallel, i will definitely try it out, this seems an easier and fast to implement option than trying to use https://github.com/autotest/autotest/wiki/ClientQuickStart , or https://github.com/amd – kamal Jan 08 '13 at 18:16

1 Answers1

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.

Smylers
  • 1,673
  • 14
  • 18
  • 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 Jan 09 '13 at 14:37
  • @kamal You can install `cpanm` locally with `wget -O - http://cpanmin.us | perl - --self-upgrade -l` – Smylers Jan 09 '13 at 15:01