CONTENTS

Home
Projects
  Electronics
  Graphics
  Java
  Java Mobile
  Android
  Other Stuff
Resume
Music
Pictures
Contact



MIKEHUP

By Michael Kohn (mike@mikekohn.net)
http://www.mikekohn.net/

CONTENTS
INTRODUCTION
LICENSE/DOWNLOAD
COMPILING
PROBLEMS (FAQS)


INTRODUCTION

This is mikehup (errr.. my rewritten version.. the original was lost by my ISP that didn't backup my web page. Thanks guys! :)

Anyway, this program solves the problem that PHP cannot execute a program in the background. Actually, PHP CAN execute a program in the background if the program being called closes stdin, stdout, and stderr. For example, if you had a web page that would play an mp3 on your local computer, the PHP code would have something like this in it:

system("mpg123 yngwie.mp3 &");

Unfortunately the & will not let mpg123 run as a background process because mpg123 keeps stdin, stdout, and stderr open. Therefore, the page will not finish loading until the mp3 is done playing.

Since most people don't want to play with the source code for mpg123 and a lot of programs don't give you the source code at all, I created mikehup. When you call a program with mikehup, it will close stdin, stdout, and stderr before executing your program. This allows your program to run in the background and your web page will load immediately without waiting for it to finish. The new PHP code would look something like this:

system("/usr/local/bin/mikehup mpg123 yngwie.mp3 &");

REMEMBER to check paths to files (you may need /usr/local/bin/mpg123 to make it run) and don't forget the & at the end of the line.

Update Dec 12, 2005: I recently received an email from Mark Mitchell (Thanks Mark!) telling me this works on Windows XP. I'd would think this would work also on Windows 2000 and NT, not 100% sure about Windows 98/ME/95. His setup was PHP5 in CGI mode under IIS. His example looks like this:

<?php

$cmd = "start /B /D c:\php_sys c:\php_sys\mikehup.exe c:\php\php.exe -f blah.php blah.xml >NUL";
pclose(popen($cmd,'r'));
?>

Anyway, I hope this helps the people who keep emailing me asking for mikehup. If you like this program just send me money :). Or maybe just a "thank you" email would be cool too.. :)

Enjoy!

-Mike


LICENSE/DOWNLOAD

This program is under the Kohnian Honor System (KHS) License. It assumes you are not a jerk and you're not going to take this source code and take my name out and put your name in and ignorant things such as that.. :) Feel free to spread it around!

Download:
mikehup-1.00.tar.gz (August 15, 2001)
mikehup-1-1.i586.rpm (RPM by Willy Frissen <willy@plato.nl>)
mikehup-1.00.zip (Binary for Windows NT/95 users Update: Been told this works on Windows XP)


COMPILING

To uncompress/unarchive type:

tar xvzf mikehup-1.00.tar.gz
cd mikehup

Then to compile type:

make
make install


PROBLEMS/SOLUTIONS (FAQS)

Writing on the command line: mikehup ls -la > text.txt creates an empty file

The problem is mikehup will close stdin, stdout, and stderr. The Unix shell interprets this as mikehup ls -la and write the output of that to text.txt. Since mikehup closes stdout, there will never be any output. The correct way to fix this is to write:

mikehup "ls -la > test.txt"




Copyright 1997-2012 - Michael Kohn

This page was designed to work with all standard HTML compatible web browsers including Firefox, IE, Safari, and Links.