Hi,
From a win32 program compiled with winelib I am trying to execute the
following: FILE *program; if (program = popen("dcop amarok player nowPlaying", "r")) fgets(buff, sizeof(buff), program); The idea is to read the current track amarok's playing. But I keep receiving the following text: "File not found". Later I tried changing to : popen("ls", "r"), and the same problem arised. Finally I changed to popen("dir", "r") and then I got some data read (first line of the dir command). So, what I understand is that the popen function is opening/reading only windows programs. How can I make it open a pipe on a Linux' one? Is there something like linux_popen()?
Thanks. Sergio.
Sergio wrote:
Hi,
From a win32 program compiled with winelib I am trying to execute the
following: FILE *program; if (program = popen("dcop amarok player nowPlaying", "r")) fgets(buff, sizeof(buff), program); The idea is to read the current track amarok's playing. But I keep receiving the following text: "File not found". Later I tried changing to : popen("ls", "r"), and the same problem arised. Finally I changed to popen("dir", "r") and then I got some data read (first line of the dir command). So, what I understand is that the popen function is opening/reading only windows programs. How can I make it open a pipe on a Linux' one? Is there something like linux_popen()?
Thanks. Sergio.
OK. It's me, the same person of the original post (I just changed my e-mail adress).
I just imagined that what I needed to do could be achieved by creating a separate source file which will be compiled using gcc against the standard linux's libraries. Then I compiled the rest of the program and linked everything together. Now, when I tried to run the application to just do: program = popen("ls .", "r") I got a message in the console saying "err: broken pipe". To make the binary I did: 1) gcc -c linuxsource.c -o linuxsource.o 2) wingcc -c restofprogram.c -o restofprogram.o 3) To link: wingcc -share binaryname.spec restofprogram.o linuxsource.o resource.res -L/usr/local/lib/wine -lwine -lmsvcrt -lgdi32 -lshell32 -lole32 -lcomctl32 -lcomdlg32 -o binaryname.dll And well, I am actually making a dll not a program.
What's the problem here?
Thanks. Sergio.
Sergio Tridente wrote:
Sergio wrote:
Hi,
From a win32 program compiled with winelib I am trying to execute the
following: FILE *program; if (program = popen("dcop amarok player nowPlaying", "r")) fgets(buff, sizeof(buff), program); The idea is to read the current track amarok's playing. But I keep receiving the following text: "File not found". Later I tried changing to : popen("ls", "r"), and the same problem arised. Finally I changed to popen("dir", "r") and then I got some data read (first line of the dir command). So, what I understand is that the popen function is opening/reading only windows programs. How can I make it open a pipe on a Linux' one? Is there something like linux_popen()?
Thanks. Sergio.
OK. It's me, the same person of the original post (I just changed my e-mail adress).
I just imagined that what I needed to do could be achieved by creating a separate source file which will be compiled using gcc against the standard linux's libraries. Then I compiled the rest of the program and linked everything together. Now, when I tried to run the application to just do: program = popen("ls .", "r") I got a message in the console saying "err: broken pipe". To make the binary I did:
- gcc -c linuxsource.c -o linuxsource.o
- wingcc -c restofprogram.c -o restofprogram.o
- To link: wingcc -share binaryname.spec restofprogram.o linuxsource.o
resource.res -L/usr/local/lib/wine -lwine -lmsvcrt -lgdi32 -lshell32
Here is the problem ^ you are linking with msvcrt so you are getting the msvcrt version of popen.
-lole32 -lcomctl32 -lcomdlg32 -o binaryname.dll And well, I am actually making a dll not a program.
Rob
Rob Shearman wrote:
Sergio Tridente wrote:
Sergio wrote:
Hi,
From a win32 program compiled with winelib I am trying to execute the
following: FILE *program; if (program = popen("dcop amarok player nowPlaying", "r")) fgets(buff, sizeof(buff), program); The idea is to read the current track amarok's playing. But I keep receiving the following text: "File not found". Later I tried changing to : popen("ls", "r"), and the same problem arised. Finally I changed to popen("dir", "r") and then I got some data read (first line of the dir command). So, what I understand is that the popen function is opening/reading only windows programs. How can I make it open a pipe on a Linux' one? Is there something like linux_popen()?
Thanks. Sergio.
OK. It's me, the same person of the original post (I just changed my e-mail adress).
I just imagined that what I needed to do could be achieved by creating a separate source file which will be compiled using gcc against the standard linux's libraries. Then I compiled the rest of the program and linked everything together. Now, when I tried to run the application to just do: program = popen("ls .", "r") I got a message in the console saying "err: broken pipe". To make the binary I did:
- gcc -c linuxsource.c -o linuxsource.o
- wingcc -c restofprogram.c -o restofprogram.o
- To link: wingcc -share binaryname.spec restofprogram.o linuxsource.o
resource.res -L/usr/local/lib/wine -lwine -lmsvcrt -lgdi32 -lshell32
Here is the problem ^ you are linking with msvcrt so you are getting the msvcrt version of popen.
-lole32 -lcomctl32 -lcomdlg32 -o binaryname.dll And well, I am actually making a dll not a program.
Rob
I see. But I need to link to msvcrt for the rest of the functions in the dll I am trying to make. I only need popen to be linked using linux' libraries. Do you know what I can do to have both things (standard popen and wine's libraries for the rest of the dll)?
Thanks.
Sergio wrote:
I see. But I need to link to msvcrt for the rest of the functions in the dll I am trying to make. I only need popen to be linked using linux' libraries. Do you know what I can do to have both things (standard popen and wine's libraries for the rest of the dll)?
A second dll maybe. (That is not liked to msvcrt)
Also one more thing you could do is a small Winelib app (run_unix.exe.so) that communicates STDIN STDOUT raw style through GetStdHandle / ReadFile /WriteFile (see MSDN). and in tern popen() a Linux process. So you do:
<Winelib_code> popen("run_unix param1 param2 ..." ,"rb+") ; </Winelib_code>
Such a program could also be useful for a Native app that needs to run a Linux application.
Free Life Boaz
Boaz Harrosh wrote:
Sergio wrote:
I see. But I need to link to msvcrt for the rest of the functions in the dll I am trying to make. I only need popen to be linked using linux' libraries. Do you know what I can do to have both things (standard popen and wine's libraries for the rest of the dll)?
A second dll maybe. (That is not liked to msvcrt)
what about dlopen/dlsym on (g)libc + popen ?
Also one more thing you could do is a small Winelib app (run_unix.exe.so) that communicates STDIN STDOUT raw style through GetStdHandle / ReadFile /WriteFile (see MSDN). and in tern popen() a Linux process. So you do:
<Winelib_code> popen("run_unix param1 param2 ..." ,"rb+") ; </Winelib_code>
Such a program could also be useful for a Native app that needs to run a Linux application.
we should even try to integrate it to popen in builtin msvcrt A+
Eric Pouech wrote:
Boaz Harrosh wrote:
Sergio wrote:
I see. But I need to link to msvcrt for the rest of the functions in the dll I am trying to make. I only need popen to be linked using linux' libraries. Do you know what I can do to have both things (standard popen and wine's libraries for the rest of the dll)?
A second dll maybe. (That is not liked to msvcrt)
what about dlopen/dlsym on (g)libc + popen ?
Thanks! dlopen/dlsym did the trick!
Also one more thing you could do is a small Winelib app (run_unix.exe.so) that communicates STDIN STDOUT raw style through GetStdHandle / ReadFile /WriteFile (see MSDN). and in tern popen() a Linux process. So you do:
<Winelib_code> popen("run_unix param1 param2 ..." ,"rb+") ; </Winelib_code>
Such a program could also be useful for a Native app that needs to run a Linux application.
we should even try to integrate it to popen in builtin msvcrt A+
Eric Pouech wrote:
Boaz Harrosh wrote:
Such a program could also be useful for a Native app that needs to run a Linux application.
we should even try to integrate it to popen in builtin msvcrt A+
What do you mean? with a check for a "special" app_name. Or an auto-detection of the binary and delegation to (g)libc - popen? And bridge of Wine-std-I/O to Linux-std-I/O.
I thought about it a bit, The I/O bridging will have to be either done with threads, or with async I/O in Read/WriteFile and accept on the Linux side.
Free life Boaz
Boaz Harrosh wrote:
Eric Pouech wrote:
Boaz Harrosh wrote:
Such a program could also be useful for a Native app that needs to run a Linux application.
we should even try to integrate it to popen in builtin msvcrt A+
What do you mean? with a check for a "special" app_name. Or an auto-detection of the binary and delegation to (g)libc - popen? And bridge of Wine-std-I/O to Linux-std-I/O.
I thought about it a bit, The I/O bridging will have to be either done with threads, or with async I/O in Read/WriteFile and accept on the Linux side.
why would you need dedicated threads ? you just need to link parent's handles to unix fd created for child (you may have for simplicity to implement Unix popen in msvcrt, but that shouldn't be too hard)
A+