in reply to Detect options of script runnning in a demon mode
Normally I'd just have the daemon print the command line it is called with to a specific file and have the script read that file.
If for some reason that doesn't work and you happen to be on Linux, you can get the exact command line a process was called with by examining the /proc/<process id>/cmdline file. So, for example, the below code will print out the command line:
#!/usr/bin/perl use warnings; use strict; open (my $fh,"<","/proc/$$/cmdline") or die "Can't access proc file: $ +!"; my $line = (<$fh>); close $fh or die "Can't close proc file: $!"; my @cmdline = split("\0",$line); print join(" ",@cmdline)."\n";
|
|---|