By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,908 Members | 2,041 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,908 IT Pros & Developers. It's quick & easy.

cannot start a Process and access standardInput

P: n/a
I looked at
http://www.codeproject.com/csharp/La...target=process and
tried to follow the code there. My code is:

public class Test
{
public ProcessStartInfo StartInfo;
public StreamWriter R_Input;
public StreamReader R_Output;
public Process Rprocess = new Process();

public Test()
{
}

public void StartR()
{
StartInfo = new ProcessStartInfo(
@"C:/Program Files/R/rw1062/bin/Rterm.exe",
@"--no-restore --no-save");

StartInfo.RedirectStandardInput = true;
StartInfo.RedirectStandardOutput = true;
StartInfo.UseShellExecute = false;
StartInfo.CreateNoWindow = false;
Process.Start(StartInfo); //line 12

R_Input = Rprocess.StandardInput; //ine 13
}
}

I can see the process start correctly after line 12 (it appears in the
Windows Task Manager, and a console starts up). But line 13 always raises
the exception:
"StandardIn has not been redirected."

I don't know much about the program Rterm.exe itself
(http://www.r-project.org/), but the documentation would imply no problem in
redirecting stdIn and stdOut in a .bat file:

"Otherwise you can set up a batch file using Rterm.exe. A sample batch file
might contain (as one line)

path_to_R\bin\Rterm.exe --no-restore --no-save < %1 > %1.out 2>&1"
Can someone suggest a cause and a fix for this problem?
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> Process.Start(StartInfo); //line 12
R_Input = Rprocess.StandardInput; //ine 13

I can see the process start correctly after line 12 (it appears
in the Windows Task Manager, and a console starts up).
But line 13 always raises the exception:
"StandardIn has not been redirected."


Um... in line 12 you get the actual process that was created. Store that
reference in Rprocess. In other words, change line 12 to:

Rprocess = Process.Start(StartInfo);

That should work,
-JG
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.