2

I have this Ruby script (test.rb):

print "hello"

And I have this PHP script (test.php):

$cmd = "ruby test.rb";
system($cmd);

Now I call my PHP script from CLI this way:

php test.php

And I get no output (it should print "hello")

Why?

2
  • Did you miss a semicolon in your PHP file? Commented Dec 22, 2011 at 13:21
  • I don't know about the PHP, but you probably want puts "Hello". print does not include a newline. Commented Dec 22, 2011 at 14:52

2 Answers 2

7

system would capture the output of the ruby script.

you might want to do:

$cmd = "ruby test.rb";
echo system($cmd);
Sign up to request clarification or add additional context in comments.

2 Comments

yes, OK, without the echo is working fine, the PHP CLI I was using was misconfigured, but now I have open another question with the real problem: stackoverflow.com/questions/8604637/…
what about if i want to run with a different user other than root. This code is running perfectly on local system but watir is not supporting for run through root user. Can you suggest @RageZ
0

Its working for me, check whether both ruby script and php in the same folder and installed ruby in your machine

<?php
$cmd = "ruby test.rb";     
system($cmd);
?>

1 Comment

what about running this script with another user as watur and headless is not supporting with root user

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.