24 Jun, 2009, Runter wrote in the 21st comment:
Votes: 0
Opps, I was accidently commenting with #. :)

If you actually want to use that code I posted you need to change it to // or /* */ for comments.

edit: I edited it above so the code is fixed now.
25 Jun, 2009, Kline wrote in the 22nd comment:
Votes: 0
Banner said:
Kline said:
http://www.ackmud.net/websvn/filedetails...
Just search for popen. I do some ugly things with it, but hey, it all works and I haven't managed to find a way to break it, yet :).

This one looks different from the one Runter quoted. What's the difference, and how would you use it to print one line from something that returns several? Or make it move directories and so something, since I don't want line counts from the area folder. -_-

Well it looks different because it's a wrapper I wrote for my own use around popen(), entirely unrelated to the snippet he posted. My _popen() simply juggles the fpReserve stream (yes, I've read the discussion on it and decided to keep it) open/closed automatically for me. All my help files are stored as individual files on disk, and I needed a creative way to access them. Here's one of the places I call my _popen(), also in db.c

int count_helps( void )
{
char buf[MSL];
char tmp[MSL];

snprintf(tmp,MSL,"expr `ls -1 -R %s | wc -l` - 26",HELP_DIR);
snprintf(buf,MSL,"%s",_popen(tmp));

return atoi(buf);
}


That function was probably one of the catalysts of doing anything at all with popen, just for MSSP support.
To print a single line from something you might just run _popen("head –lines=1 my/cool/file.ext") into a buffer. You're really only limited by your shell skills.
20.0/22