1

Let's say i have button on my form (i use c#)

private void yesButton_Click(object sender, EventArgs e)
{
}

how and what i need to write, so that i can call my ruby cmd file?

for example in cmd i write:

cd c:\ruby\ 
ruby 1.rb 
(here i need to pass some var's) 
root 
123

how can i call this in my c# .net app? also i need to see cmd output on some form component (which is best) ?

also i need to call this in "multi-task", so call this cmd let's say 10 time in ~ on time...

5
  • How would you call it from the command-line? Commented Nov 20, 2013 at 13:35
  • @MichaelPerrenoud i need to start cmd and pass there values inside form app, and then use cmd in form Commented Nov 20, 2013 at 13:39
  • Does your ruby script read from the standard input? Commented Nov 20, 2013 at 13:40
  • Try the above codeproject.com/Articles/121408/… Commented Nov 20, 2013 at 13:40
  • @JohnKällén what do you mean? yes, it's read cmd input Commented Nov 20, 2013 at 13:55

1 Answer 1

1

Alright, so you're question is still real vague, but you can do it like this:

var pathToRbFile = @"C:\Ruby193\script\123.rb";
var arguments = string.Empty; // I don't know what the arguments would be

var info = new ProcessStartInfo(pathToRbFile, arguments);
Process.Start(info);
Sign up to request clarification or add additional context in comments.

15 Comments

wouldn't the .rb file be the argument and the first parameter the path to the ruby executable in this case? otherwise this should work.
@krizz, the .rb file should already be executable by the shell in general. Process.Start leverage the normal shell execution.
@ValdisAzamaris, I don't know all of that information because I don't know anything about ruby. But as I stated in my answer, the first parameter is the fully qualified path to the .rb file and then the second parameter is a string of arguments. What that path is, and what those arguments are, that's something you'll have to work out.
forget about ruby, just imagine that i have rb file in "C:\\Ruby193\\scripts" and there i must execute command ruby 123.rb, how to write code than? also give full code, with creating class instance etc
@ValdisAzamaris, I've updated my question, but that is all the code. That's all there is to it.
|

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.