October 2006
Intermediate to advanced
888 pages
16h 55m
English
A language can’t be a glue language unless it can run external programs. Ruby offers more than one way to do this.
I can’t resist mentioning here that if you are going to run an external program, make sure that you know what that program does. I’m thinking about viruses and other potentially destructive programs. Don’t just run any old command string, especially if it came from a source outside the program. This is true regardless of whether the application is web-based.
The system method (in Kernel) is equivalent to the C call of the same name. It will execute the given command in a subshell.
system("/usr/games/fortune")
# Output goes to stdout as usual...Note that the second parameter, ...
Read now
Unlock full access