Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Help with a perl script subroutine...

 
Highlighted
MAD_2
Super Advisor

Help with a perl script subroutine...

Basically, the code has the attached subroutine.

It's called from the following lines:

#*****************************************
if ($APPLI_CNT > 0)
{
print "................>";
for ($j = 0; $j < scalar(@LES_APPLI); $j++)
{
chomp($LES_APPLI[$j]);
print "\n>>>>>>>App nber ", $j + 1, " is ", uc($LES_APPLI[$j]),"\n";
for ($t = 0; $t < scalar(@phases) ; $t++)
{
if ($LES_APPLI[$j] =~ /aaa|bbb|ccc|ddd/ )
{
$newpath = "/main/obe/$phases[$t]/$LES_APPLI[$j]/com/core";
print "check: $newpath\n";
new_path "$newpath";
}
elsif ($LES_APPLI[$j] =~ /eee|fff|ggg/ ) # special treatment needed for the CPX application
{
$environmentfile = "/main/obe/$phases[$t]/$LES_APPLI[$j]/com/etc/cfg/environment_$LES_APPLI[$j]";
print "check: $environmentfile\n";
look_for_environment "$environmentfile";
}
elsif ($LES_APPLI[$j] =~ /hhh/ ) # special treatment needed for the NGI
{
$environmentfile = "/main/obe/$phases[$t]/$LES_APPLI[$j]/com/etc/cfg/environment_com";
print "check: $environmentfile\n";
look_for_environment "$environmentfile";
}
else
{
$environmentfile = "/main/obe/$phases[$t]/$LES_APPLI[$j]/etc/cfg/environment_$LES_APPLI[$j]";
print "check: $environmentfile\n";
look_for_environment "$environmentfile";
}
}
}
}

#******************************************

Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
5 REPLIES 5
Highlighted
MAD_2
Super Advisor

Re: Help with a perl script subroutine...

This is orignally someone else's subrouting I am attempting to modify to make it fit new demands.

Problem... It's looking at the array results and what it found then attempting to remove the files when they have already been removed; it then complains with errors like the following:

++++++++++++++++++++++++++++++++++++++

/main/obe/TST1/bbb/bint/core.20050928 not found
/usr/local/bin/sudo: Illegal option -f
usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-P] [-S] [-b] [-p prompt]
[-u username/#uid] -s |
/main/obe/TST1/bbb/bint/core.20050930 not found
/usr/local/bin/sudo: Illegal option -f
usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-P] [-S] [-b] [-p prompt]
[-u username/#uid] -s |
/main/obe/TST1/bbb/bint/core.20050929 not found
/usr/local/bin/sudo: Illegal option -f
usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-P] [-S] [-b] [-p prompt]
[-u username/#uid] -s |
/main/obe/TST1/bbb/bint/core.20050926 not found
/usr/local/bin/sudo: Illegal option -f
usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-P] [-S] [-b] [-p prompt]
[-u username/#uid] -s |
/main/obe/TST1/bbb/bint/core.20050922 not found
/usr/local/bin/sudo: Illegal option -f
usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-P] [-S] [-b] [-p prompt]
[-u username/#uid] -s |
++++++++++++++++++++++++++++++++++++++

This, after the files were actually found, they were there, they were also removed as per the subroutine's params... anyone see the mistake I've made on the modifications I have used?

Thanks for any ideas...

MAD
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
Highlighted
H.Merijn Brand (procura
Honored Contributor

Re: Help with a perl script subroutine...

This is not a perl problem at all. In the end of the attached sub, you call:

system "/usr/local/bin/sudo -H -u $uid /usr/bin/rm -f $veri" ;

and the sudo you have installed states id does not support the -f option:

usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-P] [-S] [-b] [-p prompt][-u username/#uid] -s |

So you will have to consult the man page of the installed sudo to check what options do what, and what to replace -f with.
Or get yourself a working copy of the sudo that *does* support the -f in the way the author of the sub intended it to be used.

Standards++; :)

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Highlighted
Muthukumar_5
Honored Contributor

Re: Help with a perl script subroutine...

Pls do some shell work as,

# which rm

Is it /usr/bin/rm?

# touch testfile

Test 1:
# /usr/local/bin/sudo -H -u $uid /usr/bin/rm -f testfile

Test2:
# /usr/local/bin/sudo -H -u $uid /usr/bin/rm -f testfile

What are you getting for this now?

hth.


Easy to suggest when don't know about the problem!
Highlighted
MAD_2
Super Advisor

Re: Help with a perl script subroutine...

Thanks for the responses...

I must agree with procura's thought because at first I also thought this to be the issue, however the "sudo" I am using supports the "rm -f" being used. Furthermore, here is also another sub running in the same script using exactly the same sudo pattern which does not toss out any errors at all. So, this had my very intriged, and I tried a few other variations, amongst them the one pointed out by hth:

/usr/local/bin/sudo -H -u /usr/bin/rm core.20051003

The problem resulted being the same when using that pattern. However, in either case I must also state that the desired files to be removed "were removed!" So, the sudo itself is working. It appears as if it is again looking for the files which no longer exist.

About the questions last asked by hth:
1) node> which rm
/usr/bin/rm

2) I tried both (either works):
node> /usr/local/bin/sudo -H -u pdttdm /usr/bin/rm core.20051003
and
mucobt32> /usr/local/bin/sudo -H -u /usr/bin/rm -f core.20051003

So, the problem lies elsewhere (I wish I knew where)...
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
Highlighted
H.Merijn Brand (procura
Honored Contributor

Re: Help with a perl script subroutine...

Try to PRINT the command the will be executed by the system () call, and see if one of the expected arguments dropped of, so the arguments do not match

call perl with the -w option to show you undef warnings

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn