Linked Questions
69 questions linked to/from How to call shell commands from Ruby
1
vote
4answers
6k views
Run linux command in ruby [duplicate]
I'm trying to do the following..
if "ps | grep -e file" then
true;
else
false;
What would I need to do to make the string n the if statement execute the linux command listed?
1
vote
1answer
964 views
Make terminal talk from a ruby script [duplicate]
There is a operation of terminal (osx) called say. If I type say hello, the terminal uses voice control to say hello.
I want to access this command from my ruby script. Any idea how I can say hello ...
0
votes
1answer
238 views
Use terminal command in ruby code? [duplicate]
Is there any way to use command line commands in ruby code ?
Like : Some third party .ipa installer command inside ruby code(reinstall the app between scenarios using a 3rd party installer like ...
163
votes
9answers
53k views
How to trick an application into thinking its stdout is a terminal, not a pipe
I'm trying to do the opposite of "Detect if stdin is a terminal or pipe?".
I'm running an application that's changing its output format because it detects a pipe on STDOUT, and I want it to think ...
94
votes
5answers
87k views
Running command line commands within Ruby script
Is there a way to run command line commands through Ruby? I'm trying to create a small little Ruby program that would dial out and receive/send through command line programs like 'screen', 'rcsz', etc....
77
votes
5answers
43k views
Execute bash commands from a Rakefile
I would like to execute a number of bash commands from a Rakefile.
I have tried the following in my Rakefile
task :hello do
%{echo "World!"}
end
but upon executing rake hello there is no output?
...
65
votes
3answers
9k views
When to use each method of launching a subprocess in Ruby
1. `` The Backtick
defined in Kernel
1. a) %x{} Percent X < alternate syntax for The Backtick
defined in parse.y, see discussion
2. system()
Kernel#system
3. fork()
Kernel#fork, Process#fork
...
30
votes
5answers
10k views
How to integrate a standalone Python script into a Rails application?
I've got a program that has a small file structure going on and is then ran using
python do_work.py foo bar
I want my Rails users to press a button and have this happen for them, with the result ...
20
votes
3answers
28k views
How to execute commands within Rake tasks?
I have the rake tasks in my rails application. i want to run a commandline commands with in rake task. how can i do this. i tried by the following but fails
desc "Sending the newsletter to all the ...
15
votes
5answers
17k views
Call python script from ruby
For example, I can use Python scripts in PHP like there:
exec("python script.py params",$result);
where "script.py" - script name and variable $result save output data.
How I can make it with Ruby? ...
7
votes
3answers
4k views
How can an external command return both its output and its exit status to Ruby?
This is a follow up question regarding ruby system command check exit code. I want to run command such that to get its output as well as exit code. Currently what I used in the code is:
rv = `#{cmd} ...
2
votes
4answers
5k views
Call a ruby script from within a rails app controller
I'm very new to rails and I have a script that I run from the console like this
$ ruby axml2xml.rb ExamPaper.apk
Now, how do I call this script from within my controller method and pass the same ...
6
votes
1answer
4k views
Rails: possible to check if a string is binary?
In a particular Rails application, I'm pulling binary data out of LDAP into a variable for processing. Is there a way to check if the variable contains binary data? I don't want to continue with ...
2
votes
1answer
3k views
Executing grep from Ruby
I want to run the following grep from within a Ruby script:
grep "word1" file1.json | grep -c "word2"
This will find the number of lines in the file with both words appearing. I could do this with ...
3
votes
1answer
3k views
Running a Python Script in Rails
My question might be rather simple:
Where should I put python script files that I made, to run on a rails on that rails server?
And how do I call the script? (I am looking for what is the path ...