Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* running a script with sudo
@ 2001-08-28 17:12 Bryan Dunn
  2001-08-29 19:16 ` Michael Heiming
  0 siblings, 1 reply; 2+ messages in thread
From: Bryan Dunn @ 2001-08-28 17:12 UTC (permalink / raw)


Hi all,
  I am having trouble running a script with sudo permissions. I put a
line in the sudoers file which looks like this:
Cmnd_alias MOUNTCD = /usr/mount_dec_cd.pl


then later on:

username machine = MOUNTCD

The script runs fine as root, but it will not work as the user. First,
it can't use the command scu sho edt, and then produces other errors. 

What am I doing wrong?  




Here is the script itself:


    chomp ($Choice);
    if (($Choice ne "n")||($Choice ne "N")) {
         system "mkdir $Target";
    }
}

$Output = readpipe ("scu sho edt|grep -e CD-ROM -e Read-Only");
system "echo $Output";
my @Scsiid;
my $index=2;

while($Output =~ /(\s\d)/g) {
    $Scsiid[$index] = $1;
    $index--;
}

print "The Scsi ID is {$Scsiid[2] $Scsiid[1]}\n";
my $rznum = 0;
$rznum += $Scsiid[2] * 8;
$rznum += $Scsiid[1] * 1;
my $RawName = "rz${rznum}c";
print "The raw device name is $RawName\n";
system "mount -t cdfs -o ro /dev/$RawName $Target";







-- 
 ________________________________
|Bryan Dunn                      |
|Systems Administrator           |
|Raytheon Corporation            |
|E-Mail: bdunn@marmail.ed.ray.com|
|Phone: 508-490-2948             |
|Pager: 508-727-1054             |
|________________________________|


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: running a script with sudo
  2001-08-28 17:12 running a script with sudo Bryan Dunn
@ 2001-08-29 19:16 ` Michael Heiming
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Heiming @ 2001-08-29 19:16 UTC (permalink / raw)


Bryan Dunn wrote at Tuesday 28 August 2001 19:12 like only he can:

> Hi all,
>   I am having trouble running a script with sudo permissions. I put
>   a
> line in the sudoers file which looks like this:
> Cmnd_alias MOUNTCD = /usr/mount_dec_cd.pl
> 
> 
> then later on:
> 
> username machine = MOUNTCD
> 
> The script runs fine as root, but it will not work as the user.
> First, it can't use the command scu sho edt, and then produces other
> errors.
> 
> What am I doing wrong?

# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers 
file.
#
 
# Host alias specification
 
# User alias specification
 
# Cmnd alias specification
 
# User privilege specification

I somehow miss the last entry, which will be the only one you really 
need if all you want, is that one user should be able to use one 
command as root.

username        ALL=/path_to/script
         ^^^^^^^
        <TAB>

I haven't used sudo with perl scripts, but it works fine with 
binaries/shell scripts on 4.0F&5.1.

Michael Heiming


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-08-29 19:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-08-28 17:12 running a script with sudo Bryan Dunn
2001-08-29 19:16 ` Michael Heiming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox