sago has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Convert shell to perl
by andreas1234567 (Vicar) on Sep 20, 2007 at 07:26 UTC
    Pretty Good Privacy (PGP) is "is a computer program that provides cryptographic privacy and authentication". You're using the -e option which probably stands for encrypt. GNU Privacy Guard (GPG or GnuPG) is a is free replacement for Pretty Good Privacy. You can use that too.

    Type man pgp on the command line to see the documentation of the version installed on your system. Then read man chown and man chmod until you understand what the commands do. Unless you fully understand them there no point in trying to convert it.

    There are several modules on CPAN that interfaces with PGP.

    --
    Andreas
Re: Convert shell to perl
by erroneousBollock (Curate) on Sep 20, 2007 at 07:29 UTC
    I need to convert the below shell script to perl script.
    Why ? They do a very simple job,...

    i dont know what is that pgp
    can anybody tell me what those three lines of code?
    ... and it seems dubious to me that you must convert them to perl if you don't know their purpose.

    -David

Re: Convert shell to perl
by bruceb3 (Pilgrim) on Sep 20, 2007 at 08:52 UTC
    If you really need to, then -
    `sudo pgp -e test_san.dat 0x57A59396`; `sudo chown sann test_san.dat.pgp`; `sudo chgrp sanu test_san.dat.pgp`;
    OR
    system("sudo pgp -e test_san.dat 0x57A59396 >/dev/null"); system("sudo chown sann test_san.dat.pgp"); system("sudo chgrp sanu test_san.dat.pgp");
    It should be obvious now why others have been quick to question the need to move from the shell script.

    The back ticks in the first suggestion could be replaced with qx operator.

      Backticks in void context is useless. Use system() if you don't need to create the overhead of capturing all stdout (which should be obvious from the commands here).

      --
      [ e d @ h a l l e y . c c ]

Re: Convert shell to perl
by swampyankee (Parson) on Sep 20, 2007 at 15:42 UTC

    Break this down into steps

    1. sudo is a command used in several varieties of Linux and other *ix operating systems to allow a command to be executed with root privileges.
    2. pgp is an encryption|decryption system. The -e option "-e <plaintext_filename> <recipients_userid> Instructs PGP to encrypt a plaintext file with the recipient's public key." (see PGP documentation at www.freebsd.org).
    3. chown changes the ownership of a file. In this case, it changes the ownership of test_san.dat.pgp to the user with the id of "sann"
    4. Similarly, chgrp changes the group membership for the file (*ix-like operating systems divide users into groups. File access rules can be restricted to different for members of a specific group than for those not in the group).
    5. &> is file redirection.
    6. The parentheses are used for grouping.
    7. and most importantly read the documentation.

    I've found that the man pages are wonderful sources of information. If the man pages aren't on your system, The FreeBSD Project, SUSE, and many others maintain on-line documentation sites.


    Editorial corrections


    emc

    Information about American English usage here and here.

    Any Northeastern US area jobs? I'm currently unemployed.