[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

how to get into a variable the result of exec() in php

Posted on 2016-10-02
4
Medium Priority
?
65 Views
Last Modified: 2016-10-03
Hi

I got an example fortran executable that use two numbers as a parameters and add them and the result is printed in the command prompt

Right now im using a cgi perl script to print the result of the fortran executable in a webpage and it works great, but i would like to know if is it posible to get the result of my program into a variable and echo that variable.

At this moment im trying the following code
<?php
$salida = array();
exec("C:\xampp\cgi-bin\prueba6.exe 1000 1000",$salida);
echo $salida[0];
?>

Open in new window


but all the time i got the following error: "Notice: Undefined offset: 0 in C:\xampp\htdocs\prueba1.php on line 5"

What im doing wrong???
0
Comment
Question by:altariamx2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 41825709
What do you get if you run the program on the command line?
0
 
LVL 9

Accepted Solution

by:
Brian Tao earned 2000 total points
ID: 41825870
I don't think the program is even called and running.  The "\"s (backslashes) need to be escaped, so your line #3 should become:
exec("C:\\xampp\\cgi-bin\\prueba6.exe 1000 1000",$salida);

Open in new window

or just use forward slashes "/"'s and you're fine.
0
 

Author Closing Comment

by:altariamx2003
ID: 41826345
it works!!!

thanks a lot
1
 
LVL 9

Expert Comment

by:Brian Tao
ID: 41826573
You're welcome.  Glad to help.
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question