#!/usr/bin/perl -w use strict; my $pid = $$; my ($IPaddress) = @ARGV; # Save our PID into the pidfile: my $pidfile = "/home/ember/devices/$Macaddress/$pid.pid"; open (FILE, "> $pidfile") or die "Can't create file $pidfile: $!\n"; print FILE "$pidfile\n"; close FILE; # and replace ourselves with the real program, which gets the same PID as we had: exec 'other.pl', $IPaddress;