Here I have one command which is like interactive mode:
obex_test -b $BD_ADDR $CH_NUM
This command is from a script but I want to run this command through a system call in a C program.
obex_test is nothing but obex file transfer library.
Here I want to receive a file from remote device to local device through bluetooth.
This is the manual page of obex_test
Please can anybody tell me how can I put my C program in interactive mode like this command, and I want to use this command also.
I used popen(command,"r") but its not useful; it does not take input from the user.
If I used "w" mode then I don't know what happens; I directly get a message like >Unknown Command. It's the error this command gives when we give different options. So it's taken something as a write mode.
You could have two pairs of pipes (created with the pipe(2) system call); one for data from your program to
obex_test's stdin and one fromobex_test's stdout to your program. Then you wouldforkandexecve... Beware of deadlocks (your program blocked on writing toobex_teststdin when its output pipe is full and blocking it), you might need to call poll(2) orselect(2)...However, as it man pages explain, "
obex_testis a test application for thelibopenobexlibrary". So why don't call directly functions inside this libopenobex library, which you would link to your program?