1

In a Rails web application program, I need to run a bash script (on the linux OS ) in the Rails environment, but I don't know how to connect my script to the Rails in order for Rails to read & run my script then send the output of script to Rails so that meet my needs.

For example, I have a server with ip:1.1.1.1 ,and write the script in the path: /usr/local/scripts/hello.sh, but whenever I run hello.sh script on this server, it prints " hello world" in the output, but my Rails applicaton is running on the server with ip:1.1.1.2. Now, I need to run hello.sh via the Rails web application on server 1.1.1.2 to send me on the webpage the output: "hello world". that is simple example to say what i need.

myscript: for example

#!/bin/bash
echo "hello world"

OS=LINUX

EDIT

describe it in the simple way:

  • I have 2 servers ip of server A:1.1.1.1 ip of server B:1.1.1.2
  • I have a scripts in (server A). Path to the script: /usr/local/script/hello.sh
  • The content on hello.sh is : #!/bin/bash echo "hello world"

I am going to call hello.sh (located on server A) using rails3 application (running on server B). In order to display the result of hello.sh (hello world) on the web page on server B.

1
  • Just to clarify hello.sh is stored on server A must be executed inside Rails application on server B right? Commented Nov 16, 2011 at 12:30

1 Answer 1

3

system command ?

E.g:

system('sh http://1.1.1.1/yourscript.sh')

to get the output look here : Getting output of system() calls in Ruby

Sign up to request clarification or add additional context in comments.

7 Comments

Thanks alot for your reply, i am realy in need, but what sections of rails must be write this command ?what folder or path?
how to send the result of hello.sh to the server that running rails in order to display "hello world" in the web page
call it in the controller when it is required
this command dosn't work i get the error in "irb" system('sh 1.1.1.1/yourscript.sh')
describe it in the simple way: ------------------------- i have 2 server ip of server a:1.1.1.1 ip of server b:1.1.1.2 ---------- i have a scripts in (server a) in the blow path: /usr/local/script/hello.sh the content on hello.sh is : ------------------ #!/bin/bash echo "hello world" -------------------- i am going to call hello.sh (located on server a)using web programming via rails3 (running on server b) in order to display the result of hello.sh(hello world) on the web page on server b that is designed via rails web programming
|

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.