Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: HELP chgrp

by Trix606 (Monk)
on Oct 20, 2005 at 14:25 UTC ( #501675=note: print w/replies, xml ) Need Help??

in reply to HELP chgrp

This "module" installs Perl programs that mimic Unix commands. These programs are installed in a usr\local\ppt\bin directory off the root directory. Batch files corresponding to each Perl program are also installed in that directory. On a MS operating system you just need to add usr\local\ppt\bin to your path. On a *nix system you already have those commands built-in.

Replies are listed 'Best First'.
Re^2: HELP chgrp
by Ronnie (Scribe) on Oct 20, 2005 at 15:43 UTC
    Sorry to burden you but as you've been the only monk to help...... I can now find the chgrp script on the path that you pointed me at. I still however am unsure how to call chgrp!
    use lib '/usr/local/ppt/bin' ; # print "\n\tMod Test Starts\n" ; # my $file = 'xxrctest' ; my $new_group = 'save' ; # &chgrp ($new_group $file) or die "\n\tNo kin n d min ::$!\n" ; # print "\n\tMod Test Ends\n" ;
    results in -
    $ Scalar found where operator expected at line 17, near "$ne +w_group $f ile" (Missing operator before $file?) syntax error at line 17, near "$new_group $file" Execution of aborted due to compilation errors.
    If I remove the & from the &chgrp call I get -
    $ Scalar found where operator expected at line 17, near "$ne +w_group $f ile" (Missing operator before $file?) syntax error at line 17, near "$new_group $file" Execution of aborted due to compilation errors.
    How, before I'm completetly bald!, do I call this script?
    Cheers, Ronnie
      As i stated previously in your other node
      You cannot get any sub-routines or functions from this script, if you *really must* use this script, then you will have to run it through system:
      system("$path_to_bin/chgrp $new_group $file")

      This is not a Signature...
      No burden. monkey_boy had the right answer, you need to use system().

      These programs are intended to be run from a command line via the MSDOS batch files that are in the \usr\local\ppt\bin directory. While these batch files DO call Perl scripts, I'd think twice about calling those scripts directly without looking at how the batch file calls the script.

      To me the safest way to call it is calling the batch file using the system() function.

      (Missing operator before $file?)

      I'm not familiar with the script in question, but you definitely need an operator between those scalars, as the error message suggests. Try this:

      chgrp( $new_group, $file ) or die( 'etc.' );


      use lib '/usr/local/ppt/bin';

      Adds the path to the script to your lib path, but it doesn't actually load the script itself.

      Update: Looking at what you are trying to do in your unlinked-but-related node, what is wrong with just using chown?

      chown( -1, scalar getgrnam("save"), $file ) or die( "$! etc." );

      Note: that's an example usage, not a recommended one. Make sure that getgrnam returns something in production code.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://501675]
marto gasps at number of blocks in the Lego millennium falcon
[marto]: How many days till Christmas? ;)

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2017-12-18 21:15 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (498 votes). Check out past polls.