Run system command in perl cgi


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run system command in perl cgi
# 1  
Old 03-18-2009
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  
Old 03-18-2009
Try using sudo if it is available on your system.
# 3  
Old 03-18-2009
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  
Old 03-18-2009
Check the sudoers manpage for the NOPASSWD tag
# 5  
Old 03-18-2009
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  
Old 03-18-2009
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  
Old 03-19-2009
Can you interactively connect as www-data?
If yes, from the www-data login what prompt you get when you do "sudo su -"?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run command through html+cgi in bash

Hi everyone, I want to kill process through the web, so I create html page with single bottom that run kill command in shell script with CGI. Here is html code: <td><form METHOD="GET" action="http://IP:port/cgi_bin/script.cgi" > <input type="submit" value= "Submit" > <INPUT name="q"... (7 Replies)
Discussion started by: indeed_1
7 Replies

2. Shell Programming and Scripting

Perl system() to run a script

Hello, I'm trying to run "csso" (minify css) in a CGI script from the web panel. That is not working: Returns error 0; my $cmd = qq`csso stylesheet.css > stylesheet.min.css`; system($cmd); But that is working: my $cmd = qq`echo 'blabla' > stylesheet.min.css`; system($cmd); I'm... (12 Replies)
Discussion started by: madispuk
12 Replies

3. Shell Programming and Scripting

CGI Perl : while loop in CGI perl

Hi Team, I am trying to connect to database(succeeded ) and print the records on the browser using while loop. But the elements of array are not displayed instead while loop is displayed directly. Instead of the below I can embed html statements in print but I am looking for the below style as I... (1 Reply)
Discussion started by: scriptscript
1 Replies

4. Shell Programming and Scripting

Perl CGI : unable to download the excel sheet from perl cgi page

Hi All, I have written an cgi perl script that displays an image(Excel image) and when clicked on that Image I need to download a excel sheet. I made sure that excel sheet exists in the folder with the given name but still I am not able to download the sheet. print "<center><table... (2 Replies)
Discussion started by: scriptscript
2 Replies

5. Shell Programming and Scripting

Perl cgi pages out of cgi-bin folder in WINDOWS

Hi team, I have a typical problem with cgi pages in apache webserver in WINDOWS I am able to execute(display) the pages that are saved in cgi-bin folder. But I am not able to execute the pages stored in htdocs or other folder other than cgi-bin folder. Could anyone please let me know how... (1 Reply)
Discussion started by: scriptscript
1 Replies

6. Shell Programming and Scripting

Better way to run this perl command

i'm working with files that are huge in size. over 3GB. and i need to do a lot of pattern matching. I need a way to grep for what i want, using a tool that is available across most unix systems. i initially was gungho about grep, but not all capablities of grep are available on all OSes. so... (10 Replies)
Discussion started by: SkySmart
10 Replies

7. Web Development

problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.

Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect. Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is redirected to welcome page. My... (3 Replies)
Discussion started by: Arun_Linux
3 Replies

8. Shell Programming and Scripting

Run SCP in backgroung using Perl CGI

Hi I am Run Perl CGI Script. In which i am running SCP Command. But I want that command to be run into background and exit the script. But Still Web page waiting for Finish the script. I m doing like : system ("scp -r machinename:/path/to/file/for/copy/ /path/for/ destination/directory/ &");... (3 Replies)
Discussion started by: Navrattan Bansa
3 Replies

9. Shell Programming and Scripting

How to execute remote ssh command - Perl and CGI

Hi, I am having nightmare issue-ing remote ssh command from a CGI perl script. It just won't run on debug message: It says permission denied. Can I even do this? as the apache server running under DAEMON account probably can't execute it? Is this the case of what's going on? Here is my... (3 Replies)
Discussion started by: Dabheeruz
3 Replies

10. Shell Programming and Scripting

Perl run system command

Can perl execute a system command similar to the C function System()? Thanks. Gregg (1 Reply)
Discussion started by: gdboling
1 Replies
Login or Register to Ask a Question