Tag Archives: Tips

Compiling PHP into an EXE along with additional command line arguments

Recently I was building a simple PHP script that took the input of a CSV and extracted the data from it and feed it into a JSON-RPC based API.

Originally I had planned to automate the FTP of the CSV to the server, but then I thought if I could take the PHP file to the CSV it might be easier. The other issue I had was that I didn’t want to setup a complete server just to run a single PHP file.

Enter PHC-WIN: http://wiki.swiftlytilting.com/Phc-win

phc-win appears to be one of the simplest options for converting a simple script into a simple exe file (although a handful of DLL files are required to make the exe file run).

After testing and experimenting with the compiler, I thought “wouldn’t it be great to be able to pass some additional command line arguments to the complied file (think the filename of the CSV file).”

Well it turns out that you can. The variable that sorts the additional arguments is the “$_SERVER[‘argv’] array.

A simple print_r($_SERVER[‘argv’]); command allows you to see all the arguments and the order that they are passed to the program. It appears that the first one (position 0) is always the name of the application.

Quick, simple and easy :).

 

 

 

What’s that connector?

Computer hardware posterIf your someone that only opens up a computer every other month, or your upgrading something from a few years ago it can be hard to work out what that connector is that your trying to interface into. Well luckily Sonic840 has put together a poster to help in such situations. Check out the full sized version over at Deviantart

Components Covered Include

Ram (Both Notebook and Desktop)
Hard Drive Connectors
CPU Sockets
Processor Card Slots
Processor Card Sockets
Power Connectors
Peripheral Cards
Motherboard Back panel ports (Audio/Video/Data)
Desktop Card Slots

Buy Cables in Bulk to save money [Tips]

Buy in bulk to save on computer cables.When working with computers you can almost never have enough cables. The main cables in use are

  • IEC Power cords (also known as Kettle Cords)
  • Power Boards
  • SATA drive cables
  • Molex to SATA power adaptors
  • VGA, DVI, HDMI video leads
  • USB cables

It’s rather annoying when starting on a project and you get held up because you don’t have the correct cable for the job. (You new mother board came with 2 SATA, and your trying to install 3 SATA devices). So by investing in a little bit of cash now you can save yourself time, effort and energy down the track.

I recently needed a couple of extra SATA cables for a job and some other upgrades. Instead of going to shop and buying them for $5 each I was able to pick up a bulk pack of 10 for under $7 online, with free shipping. That’s a saving of over $43, plus 1 hour of my time (remember time is worth more than gold these days) because I didn’t have to waste that 1 going to the shop.

Command Line Mounting and Unmounting drives/volumes – Windows

Today we came across an issue while working on a virtual server. We had created a virtual hard drive, attached it to the virtual Windows 2008 Server machine, added some files to it and wanted to unmount the virtual drive and then attach it to another virtual machine.

The virtual machine manager (XenCenter in this case) wouldn’t allow us to disconnect the drive, while the virtual guest OS was still using it.

A quick Google and we finally found this command:

mountvol

Creates, deletes, or lists a volume mount point.

That’s exactly what we needed. Heres how to use it:

Creates, deletes, or lists a volume mount point.

MOUNTVOL [drive:]path VolumeName
MOUNTVOL [drive:]path /D
MOUNTVOL [drive:]path /L
MOUNTVOL [drive:]path /P
MOUNTVOL /R
MOUNTVOL /N
MOUNTVOL /E

path        Specifies the existing NTFS directory where the mount
point will reside.
VolumeName  Specifies the volume name that is the target of the mount
point.
/D          Removes the volume mount point from the specified directory.
/L          Lists the mounted volume name for the specified directory.
/P          Removes the volume mount point from the specified directory,
dismounts the volume, and makes the volume not mountable.
You can make the volume mountable again by creating a volume
mount point.
/R          Removes volume mount point directories and registry settings
for volumes that are no longer in the system.
/N          Disables automatic mounting of new volumes.
/E          Re-enables automatic mounting of new volumes.

To unmount the drive that was in use we just used:

mountvol E:\ /D

The E:\ drive was then released from Windows and this allowed us to use and mount the disk else where.