Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6581545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:09:59+00:00 2026-05-25T16:09:59+00:00

I need to run a command till the system I’m testing fails, or I

  • 0

I need to run a command till the system I’m testing fails, or I abort the script. The command I need to run may vary, so I’m taking it as a command-line argument in quotes. But I can’t seem to be able to run a command-line argument using the system command. Here’s what I tried so far (edited my attempt with the script that @Cfreak provided, even with which I see the same issue):

#!/usr/bin/perl


while(1)
{
    print "Iteration #: $count\n";
    $retval = system ($ARGV[1]);
    if( $retval != 0 ) {
        print "System call $ARGV[1] failed with code $retval\n";
    }
    $count++;
}

If I do
./run ls

I see the following prints:

System call  failed with code 65280
Iteration #: 1
System call  failed with code 65280
Iteration #: 2

What am i doing wrong here ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:09:59+00:00Added an answer on May 25, 2026 at 4:09 pm

    I believe that you want $ARGV[0] and not $ARGV[1]. You might also want to check to be sure that $ARGV[0] is present.

    if( 0 > $#ARGV )
    {
      print "No command\n";
    }
    else
    {
      while(1)
      {
        print "$count\n";
        my $ret = system( "ARGV[0]" );
        if( 0 != $ret )
        {
          print "<$ARGV[0] failed with $ret\n";
          exit;
        }
        $count++;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to run a windows command line tool from a php script on
I need to run mstest from the command line - where in the world
I sometimes need to run gacutil.exe or installutil.exe, etc. from the command line. Is
I need a doc to rtf converter that will run from the command line,
To start Diaspora sever need to run these command: cd /home/diaspora ./script/sever My server(Ubuntu
I need to run a shell command asynchronously from a Python script. By this
I am implementing a netcat clone and currently need a way to run command-line
I need to run a Linux CLI command and get its stdout output from
I need the ability to run an arbitrary command when I try and commit
I need to be able to specify a command to run when the SelectionChanged

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.