Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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.


Comment on Re: HELP chgrp
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 -
    $ Mod_test.pl Scalar found where operator expected at Mod_test.pl line 17, near "$ne +w_group $f ile" (Missing operator before $file?) syntax error at Mod_test.pl line 17, near "$new_group $file" Execution of Mod_test.pl aborted due to compilation errors.
    If I remove the & from the &chgrp call I get -
    $ Mod_test.pl Scalar found where operator expected at Mod_test.pl line 17, near "$ne +w_group $f ile" (Missing operator before $file?) syntax error at Mod_test.pl line 17, near "$new_group $file" Execution of Mod_test.pl aborted due to compilation errors.
    How, before I'm completetly bald!, do I call this script?
    Cheers, Ronnie
      (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.' );

      Additionally:

      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.

      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:
      e.g.
      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://501675]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2014-09-23 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (234 votes), past polls