The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl System command calls to variable 4scriptmoni Shell Programming and Scripting 5 11-10-2008 12:09 PM
[Perl] Accessing array elements within a sed command in Perl script userix Shell Programming and Scripting 2 10-03-2008 12:05 PM
Need Help w/PERL system command lorik Shell Programming and Scripting 1 12-06-2006 08:09 PM
perl - system command reggiej Shell Programming and Scripting 5 09-26-2005 07:52 PM
Perl run system command gdboling Shell Programming and Scripting 1 09-02-2003 10:30 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-18-2009
polki polki is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 8
Run system command in perl cgi

Hi guys,
got a problem with a perl cgi script over here. I need it to run a system command to get the status of a process. Unfortunately the process is owned by a specific user and only this user can get its status. So i tried running the command from the perl cgi with "su", but then i get the following logfile entry:
Quote:
su: must be run from a terminal
Anybody knows how to solve this problem? Another command? Another setting somewhere?
  #2 (permalink)  
Old 03-18-2009
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,861
Try using sudo if it is available on your system.
  #3 (permalink)  
Old 03-18-2009
polki polki is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 8
Gave that a shot too, but the manpage of sudo says the following:
Quote:
If the invoking user is root or if the target user is the same as the invoking user, no password is required. Otherwise, sudo requires that users authenticate themselves with a password by default
So perl just grabs the output of sudo:
Quote:
[sudo] password for www-data:
Unfortunately www-data has no password, since it is not intended to be used as a system account. And apart from that, i don't even know how to submit this password to sudo...
  #4 (permalink)  
Old 03-18-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,789
Check the sudoers manpage for the NOPASSWD tag
  #5 (permalink)  
Old 03-18-2009
polki polki is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 8
Thanks for the hint. Sounded like the right way, tried it by adding
Quote:
www-data ALL=NOPASSWD: ALL
to /etc/sudoers. Still the same log entry...
  #6 (permalink)  
Old 03-18-2009
polki polki is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 8
Ok, seems like now the problem shifted a bit. After trying sudo from within perl, the auth-logfile showed this line:
Quote:
Mar 18 21:41:58 Debian sudo: pam_unix(sudo:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost= user=www-data
So from root i su'ed to ww-data and tried entering the command directly from within the command line. Result is this in auth.log:
Quote:
Mar 18 21:43:01 Debian sudo: pam_unix(sudo:auth): conversation failed
Mar 18 21:43:01 Debian sudo: pam_unix(sudo:auth): auth could not identify password for [www-data]
Mar 18 21:43:01 Debian sudo: www-data : pam_authenticate: Kommunikationsfehler ; TTY=pts/0 ; PWD=/var/log ; USER=<my desired user> ; COMMAND=<my desired command>
"Kommunikationsfehler" would mean something like communication failure or conversation failure in english.

Now I don't know how to continue at all. I just don't know Linux quite this well. Anybody got me ideas?
  #7 (permalink)  
Old 03-19-2009
rikxik's Avatar
rikxik rikxik is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 250
Can you interactively connect as www-data?
If yes, from the www-data login what prompt you get when you do "sudo su -"?
Sponsored Links
Reply

Bookmarks

Tags
cgi, perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0