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.