LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-26-2011, 09:31 PM   #31
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1

oh well i did what i could.
my username is apache and i also chan the path to /usr/sbin/dmidecode because my system also got it. and i also insert sudo dmidecode inside my bash script. but it didnt work =_=

Last edited by athrin; 04-26-2011 at 09:40 PM.
 
Old 04-26-2011, 10:20 PM   #32
micxz
Senior Member
 
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Quote:
Originally Posted by athrin View Post
oh well i did what i could.
my username is apache and i also chan the path to /usr/sbin/dmidecode because my system also got it. and i also insert sudo dmidecode inside my bash script. but it didnt work =_=
Why don't you post what you have exactly in sudoers and in your bash script? Also I thought you said php why are we back to bash again?
 
Old 04-26-2011, 10:32 PM   #33
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
inside visudo
Quote:
# 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

# Defaults specification

# User privilege specification
root ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now

apache ALL = NOPASSWD: /usr/sbin/dmidecode
inside my bash
Code:
#!/bin/bash

echo "Content-type: text/html"
echo ""
echo "<html><head><title>Server Detail</title></head>"
echo "<body>"

NAME2=$1
echo -e "<p>NAME         :$NAME1</p>"

sudo dmidecode | grep Number > /var/www/cgi-bin/dmidecode

Serial=`cat /var/www/cgi-bin/dmidecode | head -n1 | cut -d: -f2`
echo "<p>Serial"'          '":$Serial</p>"
echo "</body></html>"
inside my php
Code:
<html><head><title>Enter Details
</title></head><body>


<form name="detailfrm" method="post" action="">
<table>
<tr>
    <td>Enter Name</td>
    <td>:</td>
    <td><input type="text" name="Name"></td>
</tr>
<tr>
    <td><input type="submit" value="Submit" name="detailbtn"></td>
</tr>
</table>
</form>
</body></html>

<?php

if(isset($_POST["detailbtn"]))
{
$name1=$_POST["Name"];
$name2="....";
putenv("Name1=$name1");
system("/var/www/cgi-bin/testing.sh $name2");
}
?>
is this enough?

Last edited by athrin; 04-26-2011 at 10:34 PM.
 
Old 04-26-2011, 10:41 PM   #34
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by micxz View Post
Why don't you post what you have exactly in sudoers and in your bash script? Also I thought you said php why are we back to bash again?
well i said that i want my dmidecode command inside bash to be able to run with web browser. in php it will ask for name like example and the name along with serial will be display inside browser.

if you got other method. please tell me

Last edited by athrin; 04-26-2011 at 10:43 PM.
 
Old 04-27-2011, 12:44 AM   #35
micxz
Senior Member
 
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
How about eliminating the bash script all together and use this in place of the php system call:

Code:
system("sudo /usr/sbin/dmidecode | grep Number | head -n1 | cut -d: -f2");
 
Old 04-27-2011, 12:51 AM   #36
micxz
Senior Member
 
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
In the bash script which I suggest you don't use I see an error here:
Code:
NAME2=$1
echo -e "<p>NAME         :$NAME1</p>"
should be:
Code:
NAME1=$1
echo -e "<p>NAME         :$NAME1</p>"
 
Old 04-27-2011, 01:15 AM   #37
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by micxz View Post
In the bash script which I suggest you don't use I see an error here:
Code:
NAME2=$1
echo -e "<p>NAME         :$NAME1</p>"
should be:
Code:
NAME1=$1
echo -e "<p>NAME         :$NAME1</p>"
didnt work for me. is it work for you?

Quote:
system("sudo /usr/sbin/dmidecode | grep Number | head -n1 | cut -d: -f2");
if i use this the name or other command such as ip addrs that is if i want to add something wont show.

if only this code will run with browser
Code:
sudo dmidecode | grep Number > /var/www/cgi-bin/dmidecode
then the problem solve.

Last edited by athrin; 04-27-2011 at 01:17 AM.
 
Old 04-27-2011, 01:26 AM   #38
micxz
Senior Member
 
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
I bet safe mode is turned on in php? Works on my laptop but safe mode is off.
 
Old 04-27-2011, 01:32 AM   #39
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by micxz View Post
I bet safe mode is turned on in php? Works on my laptop but safe mode is off.
eh2.. how come you can works but i cant *_*..
my php also already turn off. but still cant

Last edited by athrin; 04-27-2011 at 01:50 AM.
 
Old 04-27-2011, 01:52 AM   #40
micxz
Senior Member
 
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
you would do this in /etc/php.ini
 
Old 04-27-2011, 02:02 AM   #41
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
waaaa..... how come your place able to run this program while i couldn't run this program.. my php already off and i still cant run it. not fair!

Last edited by athrin; 04-27-2011 at 03:23 AM.
 
Old 04-27-2011, 08:42 AM   #42
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
Post the output of:

Code:
which dmidecode
It might be different in whatever distro you are using. I just said "/usr/sbin" because that's what Arch Linux uses.
 
Old 04-27-2011, 09:22 PM   #43
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by MTK358 View Post
Post the output of:

Code:
which dmidecode
It might be different in whatever distro you are using. I just said "/usr/sbin" because that's what Arch Linux uses.
mine also /usr/sbin/dmidecode but still cant works
 
Old 04-27-2011, 09:24 PM   #44
micxz
Senior Member
 
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
do you see anything in the http logs?
 
Old 04-27-2011, 09:31 PM   #45
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by micxz View Post
do you see anything in the http logs?
see anything?? like what?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to execute bash script from web page mustkill Linux - Server 16 05-20-2010 12:01 PM
how i can run bash script on my web? mikejosh Programming 2 04-09-2010 10:59 AM
How do I execute a bash script from a link on a web page? Is there any way to do this digilifellc Linux - Desktop 5 03-10-2010 12:24 PM
How toExecute bash scripts from web interface milescook Linux - Software 3 05-28-2006 09:44 AM
Execute bash commands from web page solomage Linux - Software 1 10-07-2004 11:54 AM


All times are GMT -5. The time now is 09:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration