Jun 12 2009

Reading outputs of an external program in C++

Published by Lord TCT under Linux, Programming Tips

Ever wanted to grab the output of a command via C++?

In PHP, we are all very familiar with @exec and popen, but what about C++?

Try this:

string cmd = “/usr/bin/netstat -na”;
string OutString;
FILE *FileStream;
char stdbuffer[1024];
FileStream = popen(cmd.c_str(), “r”);
while (fgets(stdbuffer, 1024, FileStream) != NULL)
OutString.append(stdbuffer);
pclose(FileStream);

  • The first 3 lines are variable declarations.
  • This is followed by popen command which opens a pipe to the external program. r here means to read from the program output.
  • We will now use a 1024 character buffer to read the pipe until a null terminator is encountered.
  • Remember to close the process pipe once you’re done!

You ask: “What if I want to have the stderr captured as well?”. No problem! Just add:

2>&1

to the back of your command, just like how you would do it in BASH.

May 24 2009

Nothing new?

Published by Lord TCT under Windows

Those who said Windows Vista is just Windows XP with a little interface tweak and nothing more are either extremely or just plain stupid. Though Windows 7 is already ready to go prime time, I still feel compelled to invite these ignorant people to read: http://en.wikipedia.org/wiki/Technical_features_new_to_Windows_Vista

A very good technical summary indeed.

May 09 2009

The most insecure OS?

Published by Lord TCT under Security

A picture speaks a million words:
 
xforce-os

Source: IBM Internet Security Systems X-Force® 2008 Trend & Risk Report

Apr 19 2009

Deploying SharePoint Services 3.0 (SPS 3.0)

Published by Lord TCT under Windows

This article gives a graphical and guided tutorial on how to deploy and configure a Microsoft SharePoint Services (SPS) 3.0 with Service Pack 1 on Microsoft Windows Server operating system for a company extranet.

What You’ll Need:

  1. Windows Server 2003 Service Pack 2 or Windows Server 2008
  2. Microsoft .NET Framework 3.0.
  3. Internet Information Services 6.0 or 7.0 configured and functional.
  4. Microsoft SQL Server 2000, 2005 or 2008. (Recommended)

Continue Reading »

Apr 13 2009

Making Firefox 3 Fast Again

Published by Lord TCT under Internet

Users of Firefox 3 might find it extremely slow when resolving DNS addresses when compared to Google Chrome, or even Microsoft Windows Internet Explorer 8!

The problem lies with Firefox 3’s implementation of IPv6. By default, Firefox 3 would try IPv6 first. If your network is not IPv6, where 99% of us belongs to, then Firefox 3 would wait for timeout and try with IPv4. You might have lost lots of miliseconds just waiting for IPv6 to timeout. The delay is even more apparent when accessing localhost or LAN sites.

The solution, for now, is to set the following setting to false in “about:config“:

network.dns.disableIPv6 = false

Restart Firefox 3 and enjoy the magic!

Next »