Enter and Exit subprocess from Shell Script

I am trying to enter irb from a shell script, do something, and then return to the shell script.

How can I do this?


# Some shell instructions here
four = 2 + 2
echo "This text is not reached and the process hangs open"

NOTE: I should not try to load irb to enter static code, I agree with you guys. I didn't think about what I was doing. I was interacting with an AWS library and I tried to carry that same philosophy into automating this without thinking twice about it.


You can pass a here document to irb:

irb <<SCRIPT
  four = 2 + 2
  puts four

However, I don't think that will accomplish what you are trying to do. Here is the output:

Switch to inspect mode.
  four = 2 + 2
  puts four

It is similar to bash -x. Why not simply use plain old ruby for this?

ruby <<SCRIPT
  four = 2 + 2
  puts four

There is no need to spawn an interactive shell if you aren't going to interact with it.

I think you want the answer explained from fork and exec in bash essentially:

function_to_fork() { irb }

function_to_fork &

that may not work if you want some interaction there to influence the parent process or for the parent process to wait.

My comment below didn't format very well:

With the following program I was able to achieve:

# irbb.sh
echo "here"

$ ./irbb.sh 
>> four = 2 + 2
=> 4
>> exit

Need Your Help

Event hooks for MVC unobtrusive remote validation

asp.net-mvc asp.net-mvc-3 jquery-validate unobtrusive-validation remote-validation

Is there a way to hook into MVC3 unobtrusive remote validation on the client, before data is submitted to the remote method, and after a result is returned from the remote method?

Opening Link via New Window from Javascript Select List

javascript drop-down-menu

I'm not sure what's the issue that is causing that error message when I try debugging with Firebug. Everything looks good to me.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.