why does this happen?

Discussion in 'Perl Misc' started by Uno, Sep 26, 2010.

  1. Uno

    Uno Guest

    Hello newsgroups,


    How do I not have permission here, when all I did is increment from
    perl1 to perl2. Does a file get stripped of its priveleges automatically.

    $ ./perl1.pl
    Placido P. Octopus
    Polypacido P. Octopus

    Placido P. Octopus
    Polypacido Polyp Octopus

    Placido P. Octopus
    Placido Polyp Octopus

    $ ./perl2.pl
    bash: ./perl2.pl: Permission denied
    $

    This is the source:

    $ cat perl2.pl
    #!/usr/bin/perl

    use strict;
    use warnings;

    my $string = "Placido P. Octopus\n";
    my $regex = "P.";

    my $string1 = $string;
    print $string1;
    $string1 =~ s/$regex/Polyp/;
    print $string1;
    print "\n";

    my $string2 = $string;
    print $string2;
    $string2 =~ s/$regex/Polyp/g;
    print $string2;
    print "\n";

    my $string3 = $string;
    print $string3;
    $string3 =~ s/\Q$regex/Polyp/;
    print $string3;
    print "\n";

    # that's the last perl I used
    # I build off what I have.

    my $filename = "text1.txt"
    print $filename

    $


    Thanks for you comment,
    and cheers,
    --
    Uno
    Uno, Sep 26, 2010
    #1
    1. Advertising

  2. In comp.lang.perl.misc Uno <> wrote:
    > How do I not have permission here, when all I did is increment from
    > perl1 to perl2. Does a file get stripped of its priveleges automatically.


    > $ ./perl1.pl
    > Placido P. Octopus
    > Polypacido P. Octopus


    > $ ./perl2.pl
    > bash: ./perl2.pl: Permission denied
    > $


    This is not at all related to Perl (as the leading "bash:"
    in the error messages indicates, it's something from the
    shell (bash) you're using). You don't have execute permis-
    sions for the new file 'perl2.pl', resulting from whatever
    you did but do not tell (there's no "increment" from "perl1"
    to "perl2"). Do

    chmod 755 perl2.pl

    or

    chmod +x perl2.pl

    and things will start to work again.

    Jens
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
    Jens Thoms Toerring, Sep 26, 2010
    #2
    1. Advertising

  3. Uno

    Uno Guest

    Jens Thoms Toerring wrote:
    > In comp.lang.perl.misc Uno <> wrote:


    >> Does a file get stripped of its priveleges automatically.

    > This is not at all related to Perl (as the leading "bash:"
    > in the error messages indicates, it's something from the
    > shell (bash) you're using). You don't have execute permis-
    > sions for the new file 'perl2.pl', resulting from whatever
    > you did but do not tell (there's no "increment" from "perl1"
    > to "perl2"). Do
    >
    > chmod 755 perl2.pl
    >
    > or
    >
    > chmod +x perl2.pl
    >
    > and things will start to work again.
    >
    > Jens


    Na, Jens, why the heck does my OS change permissions when I rename a file?

    $ ./perl2.pl
    Placido P. Octopus
    Polypacido P. Octopus

    Placido P. Octopus
    Polypacido Polyp Octopus

    Placido P. Octopus
    Placido Polyp Octopus

    text1.txt
    $ cat perl2.pl
    #!/usr/bin/perl

    use strict;
    use warnings;

    my $string = "Placido P. Octopus\n";
    my $regex = "P.";

    my $string1 = $string;
    print $string1;
    $string1 =~ s/$regex/Polyp/;
    print $string1;
    print "\n";

    my $string2 = $string;
    print $string2;
    $string2 =~ s/$regex/Polyp/g;
    print $string2;
    print "\n";

    my $string3 = $string;
    print $string3;
    $string3 =~ s/\Q$regex/Polyp/;
    print $string3;
    print "\n";

    # that's the last perl I used
    # I build off what I have.

    my $filename = "text1.txt";
    print "$filename\n";

    #end program

    $

    Tscheuss und gruss,
    Jens, aka,
    --
    Uno
    Uno, Sep 26, 2010
    #3
  4. Uno

    Ron Bergin Guest

    On Sep 25, 6:25 pm, Uno <> wrote:
    > Jens Thoms Toerring wrote:
    > > In comp.lang.perl.misc Uno <> wrote:
    > >> Does a file get stripped of its priveleges automatically.

    > > This is not at all related to Perl (as the leading "bash:"
    > > in the error messages indicates, it's something from the
    > > shell (bash) you're using). You don't have execute permis-
    > > sions for the new file 'perl2.pl', resulting from whatever
    > > you did but do not tell (there's no "increment" from "perl1"
    > > to "perl2"). Do

    >
    > >   chmod 755 perl2.pl

    >
    > > or

    >
    > >   chmod +x perl2.pl

    >
    > > and things will start to work again.

    >
    > >                                 Jens

    >
    > Na, Jens, why the heck does my OS change permissions when I rename a file?
    >


    Your OS won't do that, but since you didn't show us how you renamed
    the file, we can't say what you did wrong.
    Ron Bergin, Sep 26, 2010
    #4
  5. Uno <> wrote:
    >Jens Thoms Toerring wrote:
    >> In comp.lang.perl.misc Uno <> wrote:

    >
    >>> Does a file get stripped of its priveleges automatically.

    >> This is not at all related to Perl (as the leading "bash:"
    >> in the error messages indicates, it's something from the
    >> shell (bash) you're using). You don't have execute permis-
    >> sions for the new file 'perl2.pl', resulting from whatever
    >> you did but do not tell (there's no "increment" from "perl1"
    >> to "perl2"). Do
    >>
    >> chmod 755 perl2.pl
    >>
    >> or
    >>
    >> chmod +x perl2.pl
    >>
    >> and things will start to work again.
    >>
    >> Jens

    >
    >Na, Jens, why the heck does my OS change permissions when I rename a file?


    You may want to ask in NG that deals with whatever OS you are using (you
    didn't even say!).

    Aside of that Jens was right: that error message is not a Perl error
    message, it is clearly issued by your shell.

    jue
    Jürgen Exner, Sep 26, 2010
    #5
  6. Uno

    Uno Guest

    Jürgen Exner wrote:

    > You may want to ask in NG that deals with whatever OS you are using (you
    > didn't even say!).


    I x-posted to ubuntu.
    >
    > Aside of that Jens was right: that error message is not a Perl error
    > message, it is clearly issued by your shell.


    Nuts, jue, I have every belief that it wasn't perl. Maybe you can help
    me with this while the other subthread considers the part that is
    germane to perl.

    So I rename rm1.f90 to rm2.f90, and I have no problem on the command
    line except to iterate the integer that postpends the source file.

    Why is perl different?

    Gruss,
    --
    Uno
    Uno, Sep 26, 2010
    #6
  7. On Sat, 25 Sep 2010 17:30:19 -0600, Uno wrote:

    > Hello newsgroups,
    >
    >
    > How do I not have permission here, when all I did is increment from
    > perl1 to perl2. Does a file get stripped of its priveleges
    > automatically.
    >
    > $ ./perl1.pl
    > Placido P. Octopus

    <SNIP>
    >
    > $ ./perl2.pl
    > bash: ./perl2.pl: Permission denied
    > $


    I don't know how you made perl2.pl
    Try "ls -l perl1.pl perl2.pl"
    Do they both have the same permissions?
    jellybean stonerfish, Sep 26, 2010
    #7
  8. On 2010-09-26 03:33, Uno <> wrote:
    > Jürgen Exner wrote:
    >> You may want to ask in NG that deals with whatever OS you are using (you
    >> didn't even say!).

    >
    > I x-posted to ubuntu.
    >>
    >> Aside of that Jens was right: that error message is not a Perl error
    >> message, it is clearly issued by your shell.

    >
    > Nuts, jue, I have every belief that it wasn't perl. Maybe you can help
    > me with this while the other subthread considers the part that is
    > germane to perl.
    >
    > So I rename rm1.f90 to rm2.f90, and I have no problem on the command
    > line except to iterate the integer that postpends the source file.


    How did you rename the file? The mv command doesn't change the
    permissions.


    > Why is perl different?


    One difference is that a fortran source file is not directly
    executable. You cannot start it with "./rm1.f90". You have to use a
    fortran compiler to produce an execuable, and the compiler (or rather
    the linker) will set the correct permissions on the executable. A Perl
    script on the other hand can be executed, but since you create it
    (usually) with a text editor, you have to set the permissions yourself
    (since the editor doesn't know or care whether you're writing a perl
    script or a letter to your mother in law).

    hp
    Peter J. Holzer, Sep 26, 2010
    #8
  9. with <> Uno wrote:
    > Jens Thoms Toerring wrote:

    *SKIP*
    >>
    >> chmod 755 perl2.pl
    >>
    >> or
    >>
    >> chmod +x perl2.pl
    >>
    >> and things will start to work again.


    > Na, Jens, why the heck does my OS change permissions when I rename a file?


    Because you're using wrong tools. Your file manager sucks, use shell
    instead (whatever, I prefer zsh).

    *CUT*

    --
    Torvalds' goal for Linux is very simple: World Domination
    Stallman's goal for GNU is even simpler: Freedom
    Eric Pozharski, Sep 26, 2010
    #9
  10. Hadron<> writes:

    >
    > As a side note regarding perl if he's a complete beginner which seems
    > likely it might be worth suggesting he doesnt put his scripts on the
    > path and he doesn't set them for exec


    As usual, you are talking bollocks.

    He's using syntax that indicates he is *NOT* executing his scripts from
    his $PATH. And as long as you do not explicitly do what every Linux
    distribution has prevented you from doing, setting a script in your
    current directory to executable is no problem at all.

    Mart

    --
    "We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.
    Mart van de Wege, Sep 26, 2010
    #10
  11. Uno <> wrote:
    >Jürgen Exner wrote:
    >
    >> You may want to ask in NG that deals with whatever OS you are using (you
    >> didn't even say!).

    >
    >I x-posted to ubuntu.
    >>
    >> Aside of that Jens was right: that error message is not a Perl error
    >> message, it is clearly issued by your shell.

    >
    >Nuts, jue, I have every belief that it wasn't perl. Maybe you can help
    >me with this while the other subthread considers the part that is
    >germane to perl.


    ???
    No idea what you are trying to say in that paragraph.

    >So I rename rm1.f90 to rm2.f90, and I have no problem on the command
    >line except to iterate the integer that postpends the source file.


    What do you mean by "iterate the integer that postpends the source
    file"? And what's a f90 file?

    >Why is perl different?


    perl doesn't even come into the game yet. This error message "bash:
    ../perl2.pl: Permission denied" is thrown by bash _BEFORE_ bash even
    attempts to call the perl interpreter.
    It's a feature of your shell: you cannot execute a program unless you
    have execute permissions for that program. And this is the same for any
    executable file, no matter what programming language it is written in.

    jue
    Jürgen Exner, Sep 26, 2010
    #11
  12. Hadron<> wrote:
    >Jürgen Exner <> writes:
    >
    >> Uno <> wrote:
    >>>Why is perl different?

    >>
    >> perl doesn't even come into the game yet. This error message "bash:
    >> ./perl2.pl: Permission denied" is thrown by bash _BEFORE_ bash even
    >> attempts to call the perl interpreter.
    >> It's a feature of your shell: you cannot execute a program unless you
    >> have execute permissions for that program. And this is the same for any
    >> executable file, no matter what programming language it is written in.

    >
    >The same for any *file*.
    >
    >Except its not. He can "execute" the file by passing it to perl. And
    >this would be the recommended way for a noob playing with such.
    >
    >"perl ./myfile"
    >
    >"sh ./mybashscript"
    >
    >etc.
    >


    So, if I understand you correctly then you are confirming, too, that
    Perl is no different than any other programming language, right?

    jue
    Jürgen Exner, Sep 26, 2010
    #12
  13. Hadron<> writes:

    > Mart van de Wege <> writes:
    >
    >> Hadron<> writes:
    >>
    >>>
    >>> As a side note regarding perl if he's a complete beginner which seems
    >>> likely it might be worth suggesting he doesnt put his scripts on the
    >>> path and he doesn't set them for exec

    >>
    >> As usual, you are talking bollocks.
    >>
    >> He's using syntax that indicates he is *NOT* executing his scripts from
    >> his $PATH. And as long as you do not explicitly do what every Linux
    >> distribution has prevented you from doing, setting a script in your
    >> current directory to executable is no problem at all.

    >
    > I suggested that its not on the path IN CASE : hence I mentioned
    > SPECIFICALLY running perl. At no point did I say they are currently on
    > the path either.
    >

    Actually, you did. Otherwise your suggestion that he shouldn't put his
    scripts in his $PATH wouldn't make any sense.

    Then again, you seldom make any sense anyway.

    > My POINT was that you DONT NEED exec permissions when developing when
    > you specifically invoke perl.
    >

    Then you shouldn't have said so. Instead you strongly suggested that
    it's not a matter of *need*, but a matter of *don't*. Which, as I
    explained, is unnecessary in this case, as the OP is obviously aware how
    to execute a file in his cwd.
    >
    > That is VERY common during development : I dont expect you to understand.
    >

    I suspect I write more perl during a working day than you have done in
    your entire life.

    > You're a moron.


    Coming from you, that's a compliment.

    Sorry to the clpm guys, but Hadron is a known troll in aolu and advocacy
    groups (not that advocacy needs more trolls, but he alone can make up
    half the traffic in one).

    I've set follow-ups to aolu.

    Mart

    --
    "We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.
    Mart van de Wege, Sep 26, 2010
    #13
  14. On 2010-09-26 15:52, Hadron <> wrote:
    > Tad McClellan <> writes:
    >> Jürgen Exner <> wrote:
    >>> Uno <> wrote:
    >>>>So I rename rm1.f90 to rm2.f90, and I have no problem on the command
    >>>>line except to iterate the integer that postpends the source file.
    >>>
    >>> What do you mean by "iterate the integer that postpends the source
    >>> file"? And what's a f90 file?

    >>
    >> I expect that he did something like:
    >>
    >> rename 1 2 rm1.f90
    >>
    >> Though he never said what he did, which is pretty silly, as what
    >> he did is germane to what ended up happening...

    >
    > "So I rename rm1.f90 to rm2.f90,"
    >
    > Doesn't mean anything to you either?


    That would normally mean that he invoked

    mv rm1.f90 rm2.f90

    But that doesn't have to claimed effect of changing the permissions, so
    I doubt he did that.

    "rename" is not a standard POSIX command. My system has a rename
    command, but it apparently has a different syntax than Tad's rename
    command:

    rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]

    And the OP might also have used a graphical shell or some other tool.

    No use guessing. Several people have now asked the OP how he "renamed"
    the file, and we should just wait for his answer.

    hp
    Peter J. Holzer, Sep 26, 2010
    #14
  15. On 2010-09-26 14:10, Jürgen Exner <> wrote:
    > Uno <> wrote:
    >>Why is perl different?

    >
    > perl doesn't even come into the game yet. This error message "bash:
    > ./perl2.pl: Permission denied" is thrown by bash _BEFORE_ bash even
    > attempts to call the perl interpreter.
    > It's a feature of your shell: you cannot execute a program unless you
    > have execute permissions for that program. And this is the same for any
    > executable file, no matter what programming language it is written in.


    Nope. It's a feature of the OS kernel, not the shell. At least on unixes
    younger than about 20 years or so.

    hp
    Peter J. Holzer, Sep 26, 2010
    #15
  16. Hadron<> wrote:
    >So
    >"So I rename rm1.f90 to rm2.f90,"
    >Doesn't mean anything to you either?


    No, in this context it means the OP isn't telling the real story.

    The obvious interpretion of "rename" using "mv old.pl new.pl" cannot be
    right because mv doesn't change any permissions.
    Therefore there must be something else going on which the OP is not
    telling. So, no, "rename" doesn't mean anything in this context.

    jue
    Jürgen Exner, Sep 26, 2010
    #16
  17. Hadron<> writes:

    > Mart van de Wege <> writes:
    >
    >> Hadron<> writes:
    >>
    >>> Mart van de Wege <> writes:
    >>>
    >>>> Hadron<> writes:
    >>>>
    >>>>>
    >>>>> As a side note regarding perl if he's a complete beginner which seems
    >>>>> likely it might be worth suggesting he doesnt put his scripts on the
    >>>>> path and he doesn't set them for exec
    >>>>
    >>>> As usual, you are talking bollocks.
    >>>>
    >>>> He's using syntax that indicates he is *NOT* executing his scripts from
    >>>> his $PATH. And as long as you do not explicitly do what every Linux
    >>>> distribution has prevented you from doing, setting a script in your
    >>>> current directory to executable is no problem at all.
    >>>
    >>> I suggested that its not on the path IN CASE : hence I mentioned
    >>> SPECIFICALLY running perl. At no point did I say they are currently on
    >>> the path either.
    >>>

    >> Actually, you did. Otherwise your suggestion that he shouldn't put his
    >> scripts in his $PATH wouldn't make any sense.

    >
    > Oh ffs : his entire issue was permissions. My point, which I extended
    > on, was that he doesnt NEED permissions AND mentioned the path too.
    >

    No, you didn't phrase it like that, so stop whining if people don't read
    it like that.

    > You're not a programmer,


    I am not. I am a systems administrator that does some programming on the
    side.

    You, however, are a troll. Which you just proved by restarting the
    cross-post after I removed the off-topic groups.

    Follow-ups restored to aolu.

    Mart

    --
    "We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.
    Mart van de Wege, Sep 27, 2010
    #17
  18. Hadron<> writes:

    > Mart van de Wege <> writes:
    >
    >> Hadron<> writes:
    >>

    <snip>

    >>> You're not a programmer,

    >>
    >> I am not. I am a systems administrator that does some programming on the
    >> side.

    >
    > I figured. You're total inability to process and understand my well
    > meant reply to the OP told me all I needed to know. You're a case of a


    So, where's your contribution then? I at least have my name to a minor
    patch in a CPAN module. You have *never* produced anything.

    You can mail the proof if you want to. I'm done with you here.

    Follow-up to -9999.

    Mart

    --
    "We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.
    Mart van de Wege, Sep 27, 2010
    #18
  19. Uno

    Uno Guest

    Mart van de Wege wrote:

    > Follow-up to -9999.


    Well I hope I haven't stepped on a landmine. Thanks all for replies.
    There seems to be some smoke from other fires, so I wanted to begin with
    getting a handle on the bone-headed stuff:

    What I typically do when I begin to code for a utility like the one I
    desire is that I start with some more or less standard template, make it
    compile and perform--for perl these steps are less discrete, and see if
    I agree with my output.

    So far on ubuntu, I have only used gedit for writing source. When I've
    got the template working, I iterate the number that postpends in the
    filename. I couldn't say that any more clearly with a microphone.

    So when I rename perl2.pl to perl3.pl, this is what I get:

    $ ls -l perl*
    -rwx------ 1 dan dan 405 2010-04-01 12:37 perl1.pl
    -rw------- 1 dan dan 269 2010-04-01 12:30 perl1.pl~
    -rwxr-xr-x 1 dan dan 580 2010-09-25 21:47 perl2.pl
    -rw-r--r-- 1 dan dan 527 2010-09-25 19:20 perl2.pl~
    -rw-r--r-- 1 dan dan 580 2010-09-30 21:40 perl3.pl
    $

    Is there maybe a better way to develop perl, fortran and C on Ubuntu
    than gedit?
    --
    Uno
    Uno, Oct 1, 2010
    #19
  20. Uno

    Uri Guttman Guest

    >>>>> "U" == Uno <> writes:


    U> Mart van de Wege wrote:
    >> Follow-up to -9999.


    U> Well I hope I haven't stepped on a landmine. Thanks all for
    U> replies. There seems to be some smoke from other fires, so I wanted to
    U> begin with getting a handle on the bone-headed stuff:

    U> What I typically do when I begin to code for a utility like the one I
    U> desire is that I start with some more or less standard template, make
    U> it compile and perform--for perl these steps are less discrete, and
    U> see if I agree with my output.

    U> So far on ubuntu, I have only used gedit for writing source. When
    U> I've got the template working, I iterate the number that postpends in
    U> the filename. I couldn't say that any more clearly with a microphone.

    nope. you have been as clear as mud so far.

    HOW did you do the rename itself? you have yet to show that. the unix
    mv command will not touch permissions.

    U> So when I rename perl2.pl to perl3.pl, this is what I get:

    U> $ ls -l perl*
    U> -rwx------ 1 dan dan 405 2010-04-01 12:37 perl1.pl
    U> -rw------- 1 dan dan 269 2010-04-01 12:30 perl1.pl~
    U> -rwxr-xr-x 1 dan dan 580 2010-09-25 21:47 perl2.pl
    U> -rw-r--r-- 1 dan dan 527 2010-09-25 19:20 perl2.pl~
    U> -rw-r--r-- 1 dan dan 580 2010-09-30 21:40 perl3.pl
    U>

    i smell a rat. did you do a save as type of thing in you editor? that
    creates a new file with new permissions and likely won't enable the x
    bits. and what is so hard about doing a chmod +x on your program?

    U> Is there maybe a better way to develop perl, fortran and C on Ubuntu
    U> than gedit?

    teco if you can get it? :)

    uri

    --
    Uri Guttman ------ -------- http://www.sysarch.com --
    ----- Perl Code Review , Architecture, Development, Training, Support ------
    --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
    Uri Guttman, Oct 1, 2010
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Emilio

    MSFT Why does this happen?

    Emilio, Oct 30, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    331
    Alvin Bruney
    Oct 30, 2003
  2. Jeremy Watts

    why does this happen?

    Jeremy Watts, Aug 11, 2005, in forum: Java
    Replies:
    4
    Views:
    364
    Roedy Green
    Aug 11, 2005
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,668
    Smokey Grindel
    Dec 2, 2006
  4. Steven T. Hatton
    Replies:
    5
    Views:
    689
    Salt_Peter
    Nov 20, 2006
  5. Ken Williams

    why does this happen?

    Ken Williams, Sep 5, 2008, in forum: HTML
    Replies:
    16
    Views:
    654
    Roy A.
    Sep 7, 2008
Loading...

Share This Page