help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[example] how to get popen2() working? [XP, MSVC 2.9.15-octave]


From: John W. Eaton
Subject: [example] how to get popen2() working? [XP, MSVC 2.9.15-octave]
Date: Fri, 30 Nov 2007 14:19:12 -0500

On 30-Nov-2007, andreas.naessl wrote:

| hi all,
| 
| i try to establish a simple bidirectional pipe-connection between octave and 
| a little "server"-programm written in python, for direct data-transfer without
| producing temp-file-trash; i thought of using octave's popen2(). the server 
| should be running continuously in the background, waiting for requests.
| 
| but i cannot get it working really.
| 
| [my System: win XP + Michaels MSVC-octave 2.9.15] 
| 
| first: if i communitcate to my "server" directly at octave-prompt, 
| i get something back
| (although i don't understand the need of the fclear(b) command 
| when i want a second readline back from my server-app.) 
| please see octave-commandline-output below:
| 
|   octave.exe:35> [a,b,i]=popen2('python','svr_02.py')
|   a =  8
|   b =  7
|   i =  20204
|   octave.exe:36> fputs(a,"test_command_at promt\n")
|   ans = 0  
|   octave.exe:37> fgets(b)
|   ans = got command  test_command_at promt    ### ok
|  
|   octave.exe:38> fputs(a,"0\n")
|   ans = 0
|   octave.exe:39> fgets(b)
|   ans = -1                        ### why this ? ###
|   octave.exe:40> fclear(b)
|   octave.exe:41> fgets(b)
|   ans = got command  0           ### ok

Does

  fputs (a, "0\n");
  fflush (a);
  fgets (b)

work?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]