Solved

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

Posted on 2016-10-02
4
28 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
  • 2
4 Comments
 
LVL 82

Expert Comment

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

Accepted Solution

by:
Brian Tao earned 500 total points
Comment Utility
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
Comment Utility
it works!!!

thanks a lot
1
 
LVL 9

Expert Comment

by:Brian Tao
Comment Utility
You're welcome.  Glad to help.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now