Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Perl Programming Language

System call doesn't work


Hi, All:

I have the following perl code intending to open several files using
vi.  But it doesn't work.

ls test* | perl -n -e 'chomp; $cmd="vi $_"; unless(system($cmd))
{ print "success\n";}'

it reports error like:
"Input read error
success
"

Thanks for your help.

Steven

xlue@rogers.com wrote:
> Hi, All:

> I have the following perl code intending to open several files using
> vi.  But it doesn't work.

> ls test* | perl -n -e 'chomp; $cmd="vi $_"; unless(system($cmd))
> { print "success\n";}'

You're calling 'vi' with STDIN still connected to the pipe from 'ls'.

perl -le 'print system("vi $_") ? "error ".$?>>8 : "OK" for @ARGV' *.pl

        -Joe

On Jun 6, 6:29 pm, Joe Smith <j@inwap.com> wrote:

> xlue@rogers.com wrote:
> > Hi, All:

> > I have the following perl code intending to open several files using
> > vi.  But it doesn't work.

> > ls test* | perl -n -e 'chomp; $cmd="vi $_"; unless(system($cmd))
> > { print "success\n";}'

> You're calling 'vi' with STDIN still connected to the pipe from 'ls'.

> perl -le 'print system("vi $_") ? "error ".$?>>8 : "OK" for @ARGV' *.pl

>         -Joe

Thanks you Joe. It works.  However, how can I change the STDIN from
pipe to standard input and vice versa?

Thanks,

Steven

On Jun 7, 12:00 pm, xlue@rogers.com wrote:

Hi,

I worked out the function by unix find command:
find . -name 'test*' -exec vi {} \;

however, still cannot figure out how perl implement the same function.

Any help will be appreciated.

Thanks,

Steven

xlue@rogers.com wrote:
> I worked out the function by unix find command:
> find . -name 'test*' -exec vi {} \;

> however, still cannot figure out how perl implement the same function.

find2perl should help.
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc