- To: Rodos <rodos@xxxxxxxxxxx>
- Subject: Re: [SLUG] perl quicky
- From: Matthew Dalton <matthewd@xxxxxxxxxxxxxxxxxxxxx>
- Date: Fri Oct 13 15:27:38 2000
- Cc: djzort@xxxxxxxxxxx, SLUG Mailing List <slug@xxxxxxxxxxx>
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