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

  • Home
  • SEARCH
  • 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 6836067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:18:37+00:00 2026-05-26T23:18:37+00:00

Under Linux ,if I want to pass pure string from PHP to C, how

  • 0

Under Linux ,if I want to pass pure string from PHP to C, how do i do that?
what I’ve tried do far is:

exec("./myexec.bin -a mystring");

in PHP and

getopt(argc,argv, "a:");

in C

everything works, but when i pass strings longers than MAX_ARG_STRLEN (131072), it will no longer return 0 instead it returns 127 which is command not found….

is there any other ways to pass string data to a linux executable? or is there any way to overcome the MAX_ARG_STRLEN problem?

  • 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-26T23:18:38+00:00Added an answer on May 26, 2026 at 11:18 pm

    You could use popen() to open a pipe to the executable:

    $fp = popen('./myexec.bin', 'w');
    fwrite($fp, $data);
    pclose($fp);
    

    Then, as previously suggested, read from stdin in your C program:

    fopen(stdin, "r");
    // ...
    

    It is “safer” to use popen() rather than exec('/bin/echo') because you can write characters that would otherwise be interpreted by the shell (&, |, …). Note that the handle returned from PHP’s popen() must be closed with pclose().

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

Sidebar

Related Questions

I have the following code that works under linux. I want to port it
I want to load an XML document in Xerces-C++ (version 2.8, under Linux), and
I'm writing a few little bash scripts under Ubuntu linux. I want to be
I want to execute something in a linux shell under a few different conditions,
I have lots of home directories under /ifshome on Linux. I want to see
I want to compile a very basic hello world level Cuda program under Linux.
Using SDL 1.3 I want to create fake fullscreen SDL_Window under linux. It is
I wrote a PHP extension and it could be compiled and run under linux
I want to know if i can get/set application properties in Mono under Linux,
I want to perform the title-named action under linux command-line(several ca bash script will

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.