Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-17-2011, 05:59 AM   #1
LQ Newbie
Registered: Nov 2009
Location: Turkey
Distribution: Ubuntu
Posts: 4

Rep: Reputation: 0

FILE *fp;
char path[1035];
fp = popen("motion", "r");
while (fgets(path, sizeof(path)-1, fp) != NULL) {

no output
or terminal
root@D630:~# motion > motion.txt
motion.txt empty

ı need output motion program please help me
Old 05-17-2011, 06:25 AM   #2
Senior Member
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,533

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Please post code within CODE tags, so that the code indentation is preserved. (Please re-edit your post to add formatted code).

As for popen(), it is meant to invoke a command. It would seem the command you want to invoke is the same as the name of the executable that is calling popen()? Is this what you really want?

Here's a working example of using popen():
#include <cstdio>
#include <iostream>

int main()
   FILE* fp = popen("/sbin/ifconfig eth0", "r");

   if (fp)
      char buf[1024];

      while (fgets(buf, sizeof(buf), fp))
         std::cout << buf << std::endl;

      std::cerr << "Cannot execute /sbin/ifconfig." << std::endl;
      return -1;
   return 0;
P.S. You should avoid developing s/w under the root account.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
use of "man [page] | col -b" with popen(); mk27 Linux - General 0 09-26-2008 01:36 PM
popen on Linux redhat4.5 doesn't take "rw" ? nano2 Programming 2 03-07-2008 10:31 AM
Error with "SDL_MouseMotionEvent *motion = event->motion;" aatwell Programming 3 11-30-2007 01:46 PM
Finding pid of a process opened by "popen" Guttorm Programming 2 03-12-2007 02:35 PM
music/sound in general plays in "slow motion" tvstonydanza Linux - General 0 01-29-2004 07:29 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:31 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration