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 1006677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:29:54+00:00 2026-05-16T08:29:54+00:00

I normally call perl scripts from PHP as below and pass in variables this

  • 0

I normally call perl scripts from PHP as below and pass in variables this way, and it works fine, however now I am building a component for re-use where I want to also variablize the perl script name that I am passing in and this is giving me some headaches, so I am wondering if anyone can point out a better way to do this as my way isn’t working.. thanks..

the way that works without variablized perl filename:

$file = "/var/www/other_scripts/perl/apps/perlscript.pl $var1 $var2 $var3 $var4";
ob_start();
passthru($file);
$perlreturn = ob_get_contents();
ob_end_clean();

My attempt to variablize the perl filename that doesn’t seem to be working for me, you can see in the above how it is including even the $var(s) in the initial ” “, which I find odd but this seems to be the only way that it works and I wasn’t sure how to even replicate this with a variablized perl filename:

$perlscript_file = "/var/www/other_scripts/perl/apps/" . $perlscript .".pl";

$file = $perlscript_file . $var1 . $var2  .$var3 . $var4;
ob_start();
passthru($file);
$perlreturn = ob_get_contents();
ob_end_clean();
  • 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-16T08:29:55+00:00Added an answer on May 16, 2026 at 8:29 am

    Your way is not working because you are concatenating all the parameters without spaces, effectively making them one parameter.

    Try

    $perlscript_file = "/var/www/other_scripts/perl/apps/$perlscript.pl $var1 $var2 $var3 $var4";
    

    By the way, if the parameters are coming from an external source, you MUST sanitize them using escapeshellarg(). The same goes for $perlscript – if it comes from an external source or even user input, do a escapeshellcmd() on it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering if PHP has this optimization built in. Normally when you call foreach
Normally we use window.location.href=/index.php?querystring; in javascript. Is there a way to send the querystring
Normally I can call this.GetType(), but I can't access this in a static method.
I have a Rakefile with a Rake task that I would normally call from
Normally, I call my function like so: SELECT * FROM TABLE( package_name.function(parameters) ) I'm
So I understand this is how we normally call a jquery droppable: $( .selector
Say for example, using javascript i would normally call a method like this <a
What are alternatives to free this object? it normally happens when call the .Exit()
Normally you make a call to a service, it blocks until a thread in
I am wondering where to call the ShowDialog() in MVP pattern, Presenter is normally

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.