develooper Front page | perl.beginners | Postings from April 2002

Re: Serious problem with perl -pi -e

Thread Previous | Thread Next
From:
sharan
Date:
April 30, 2002 00:57
Subject:
Re: Serious problem with perl -pi -e
Message ID:
20020430051834.12077.qmail@onion.perl.org
Hello Peter,

I did this on Cygwin.  I followed the same steps as mentioned by you. But
still file got deleted.


sharan@SHARAN ~
$ cat foo
cat: foo: No such file or directory

sharan@SHARAN ~
$ echo "foo" > foo

sharan@SHARAN ~
$ chmod 400 foo

sharan@SHARAN ~
$ ll foo
-r--r--r--    1 sharan   None            4 Apr 30 10:39 foo

sharan@SHARAN ~
$ cat foo
foo

sharan@SHARAN ~
$ chmod 000 foo

sharan@SHARAN ~
$ cat foo
foo

sharan@SHARAN ~
$ ll foo
-r--r--r--    1 sharan   None            4 Apr 30 10:39 foo

sharan@SHARAN ~
$ perl -pi -e 's/o/e/' foo
Can't do inplace edit on foo: Permission denied.

sharan@SHARAN ~
$ cat foo
cat: foo: No such file or directory

sharan@SHARAN ~

Thanks
Sharan Hiremath.

"Peter Scott" <Peter@PSDT.com> wrote in message
news:4.3.2.7.2.20020429094246.00ba2260@shell2.webquarry.com...
> At 12:35 PM 4/27/02 +0530, sharan wrote:
> >Hello,
> >
> >I lost my files, while using perl -pi -e.
> >I wanted to replace a world in a set of files, "perl -pi -e
> >'s/somestring/somethingelse/g' *.pl"
> >but, it gave error saying permission denied and all the files got
deleted.
> >
> >If it cant rewrite the files, at least it should not delete.
>
> Can you show me how to reproduce this behavior?  Here's what happened when
> I tried, first with no write permission, then with no read permission
either:
>
> $ cat foo
> cat: foo: No such file or directory
> $ echo "foo" > foo
> $ chmod 400 foo
> $ cat foo
> foo
> $ perl -pi -e 's/o/e/' foo
> $ cat foo
> feo
> $ chmod 000 foo
> $ cat foo
> cat: foo: Permission denied
> $ perl -pi -e 's/o/e/' foo
> Can't open foo: Permission denied.
> $ cat foo
> cat: foo: Permission denied
> $ chmod 400 foo
> $ cat foo
> feo
>
> As you can see, the file was not deleted.  This was on Linux, what OS were
> you on?
>
> --
> Peter Scott
> Pacific Systems Design Technologies
> http://www.perldebugged.com
>



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About