Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] perl quicky


Rodos wrote:
> 
> On Fri, 13 Oct 2000, Dean Hamstead wrote:
> 
> > how do i get the name of current directory (basically pwd) in perl?
> 
> chop($cwd = `pwd`);
> 
> or
> 
> perl -e 'use Cwd; print "You are in the " . cwd . " directory\n";'
> You are in the /home/rodos directory
> 
> Easy.

Friday afternoon blues....

#!/usr/bin/perl
# only works on Linux :)
$pid = `ps | grep $0 | grep perl | grep -v grep | cut -d " "  -f 1`;
chomp($pid);
print `ls /proc/$pid -l | grep cwd | sed -e 's/.*cwd -> //g'`;


Matthew