Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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]
[Discipulus]: Corion are you would able to realize such thing? O_O
[Corion]: In the same vein I have a script that automates Firefox to enter some data into another system. It's not faster than the people using the script if they were to do it manually, but they prefer not having to check the data and not having typos when ...
[Corion]: ... entering the data
[Corion]: Discipulus: I don't know whether I could really do that, but the init process itself mostly launches other processes, and the whole startup is just following a path of dependencies and making sure they are all running. Which basically is what ...
[Discipulus]: when at work my time is (temporarly) owned by the firm, so i do not care (coworkers whatch movies.. I code Perl)
[Corion]: ... make already does, except for files instead of programs. But maybe with some /proc hackery, that could be eliminated and one could use plain make :-D
[choroba]: systemd just makes is asynchronous
[choroba]: so, make -j
[Corion]: Discipulus: Yeah - but when writing Perl to save time (instead of having fun), it helps to look whether you're actually saving time ;) Why spend 5 minutes doing manually what you can spend three years automating? ;)
[Corion]: choroba: Oh, yeah :-D

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2017-07-27 09:32 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (408 votes). Check out past polls.