Executing a Cygwin Process from .Net

Executing a Cygwin process from .NET?

Are you using perhaps mixing native Windows rubygems and Cygwin ruby? Using Cygwin rubygems seems to work fine for me. (Why is your Cygwin ruby interpreter apparently searching a path with Windows backslashes in it?).

Alternatively, have you tried run.exe?

C:\cygwin\bin\run.exe -p /starting/dir exe_to_run

Here's the man-page entry:

NAME

run - start programs with hidden console window

SYNOPSIS

run [ -p path ] command [ -wait ] arguments

runcommand [ -p path ] [ -wait ] arguments

DESCRIPTION

Windows programs are either GUI programs or console programs. When
started console programs will either attach to an existing console
or create a new one. GUI programs can never attach to an exiting con-
sole. There is no way to attach to an existing console but hide it if
started as GUI program.

run will do this for you. It works as intermediate and starts a pro-
gram but makes the console window hidden.

With -p path you can add path to the PATH environment variable.

Issuing -wait as first program argument will make run wait for program
completition, otherwise it returns immediately.

The second variant is for creating wrappers. If the executable is
named runcommand (eg runemacs), run will try to start the program (eg
emacs).

EXAMPLES

run -p /usr/X11R6/bin xterm

run emacs -wait
runemacs -wait

run make -wait

c#(.net) run shell script on windows by cygwin

You can use the Process class to use CYGWIN under C#.

There are other questions dealing with CYGWIN. Look at this question:
bash pipes - I am trying to call script from c#

How do you run a cygwin-compiled program from windows c# (visual studio)?

Just like any other program. Are you running any concrete well-known program or your own?

Also, see this related question here on StackOverflow: Executing a Cygwin process from .NET

bash pipes - I am trying to call script from c#

It was a path issue.

You need to set path in the script - otherwise it uses a different "non-cygwin" path and gets wrong commands.

Trouble with starting Node.js from a Cygwin console

I think this is caused by using the win distro in cygwin , since cygwin emulates a *nix environment and node.js for windows looks for the win libraries not the nix ones. In order for node.js to work in cygwin you have to build it yourslef. Also latest versions do no work on cygwin.

Current status from official wiki: Cygwin is no longer supported, despite being POSIX compliant. The latest version that compiles is 0.4.12

https://github.com/nodejs/node/wiki/Installation#building-on-cygwin

Run shell commands using C# and get the info into string

You can redirect the output with ProcessStartInfo. There's examples on MSDN and SO.

E.G.

Process proc = new Process {
StartInfo = new ProcessStartInfo {
FileName = "program.exe",
Arguments = "command line arguments to your executable",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};

then start the process and read from it:

proc.Start();
while (!proc.StandardOutput.EndOfStream) {
string line = proc.StandardOutput.ReadLine();
// do something with line
}

Depending on what you are trying to accomplish you can achieve a lot more as well. I've written apps that asynchrously pass data to the command line and read from it as well. Such an example is not easily posted on a forum.

Cygwin terminal batch file - cannot find file, but can if I run the cmd myself it does

In Windows batch scripting, the ' character is not recognised as a character for delimiting file names. Instead, " is used. Also, you would probably be better off using backslashes instead of forward slashes as path delimiters.

Thus, your script should probably look like this:

inkscape -h 120 -e "pngs\ace.png" "svgs\ace.svg"
inkscape -h 120 -e "pngs\king.png" "svgs\king.svg"
inkscape -w 120 -e "pngs\queen.png" "svgs\queen.svg"


Related Topics



Leave a reply



Submit