Hi,

I'm not sure there is an answer to this question, but here goes.

I have a program written in c++ (compiled in windows using devC++) and I can run dos commands easily using the "system function". I can also launch the cygwin bash shell by using this function. Obvously, you cannot send command prompts/lines to cygwin using the system function. Is there anyway you can send commands to cygwin via a c++ program.
Can this be done when running a devC++ compliedl program running in windows? Or alternatvly, can this be done by compliing a program within cygwin and running it from cygwin?

Thanks alot

Recommended Answers

All 3 Replies

Whilst not having anything to try it on, I would have at least given this a go. system( "c:\\cygwin\\bin\\bash.exe -l -c ls" ); -l means it's a login shell, so it runs the .profile and .rc files, to set up paths
-c means run the command line and exit.

You might be able to do this as well system( "c:\\cygwin\\bin\\ls.exe" );

Though the above functions dont work, they inspired me to the solution. I didn't realise that you could run the same commands and programs compiled on cygwin through dos in cygwins bin directory.

i.e. system("start program.exe -pqca.1 box.poly")

I thought the commands that follow the program.exe ("-pqca.1 box.poly") could only be run via cygwin. They can acutally also be run via windows dos. Fantastic!

Thanks for the help

You might be able to do this as well system( "c:\\cygwin\\bin\\ls.exe" );

You're correct here. All the files in the bin dir are executable from the command prompt. The directory structure set up for cygwin is available to these commands, so I could run, for example, ".../bin/ls.exe /c/c/matlab" where /c/c is a symbolic link set up from inside bash.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.