Thanx Brian and Bill
one approach
Actually this code is in a subroutine that returns a list of files in a
path name supplied as an argument to this subroutine
i have to do to get list of files
@data = "`ls" -ltr | grep -v total | sort +8` ;
now $? returns exist status of "sort" not "ls"
Main objective : how to make sure that "ls" command works fine ?
so one approach is divide it into two parts
@data = "`ls" -ltr ` ;
if ( $? != 0 ) {
print "ls command failed " ;
exit 1 ;
}
now
i want like
@data = "`echo" @data | grep -v total | sort +8 ` ;
this wont work ..as data is not environment variable
i can however do
ls -ltr
write output to some temporary file
then do
@data = "`cat" < file name > | grep -v total | sort +8 ' ;
but then i have to create a temp file
and write to it
and delete it
thanx
Manish
-----Original Message-----
From: Brian Noble [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 09, 2002 2:40 PM
To: [EMAIL PROTECTED]
Subject: Re: [Perl-unix-users] a way to put contents of variable at
command prompt and pip it to some other command
On Wed Oct 09, 2002 at 02:23:22PM -0700, Manish Tiwari wrote:
> Hi
>
> i was trying to do something like
>
> @data = "`ls" -ltr ` ;
how about,
if defined(@data = "`ls" -ltr`){
block of code
}
>
> < do some operation check whether ls command actually worked>
>
> now i want to pass the contents of "data" thru unix commands like egrep and
> sort
>
>
> so in all operation will be like
>
> ls -ltr | grep -v total | sort +8
>
> but making sure that ls command actually worked
>
>
> any help
>
>
> Thanx
> Manish
--
Brian Noble
Tech Support Engineer
[EMAIL PROTECTED]
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs