LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 08: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 08:40 PM.
 
Old 04-26-2011, 09:20 PM   #32
micxz
Senior Member
 
Registered: Sep 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, 09: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 09:34 PM.
 
Old 04-26-2011, 09: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 09:43 PM.
 
Old 04-26-2011, 11:44 PM   #35
micxz
Senior Member
 
Registered: Sep 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-26-2011, 11:51 PM   #36
micxz
Senior Member
 
Registered: Sep 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, 12: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 12:17 AM.
 
Old 04-27-2011, 12:26 AM   #38
micxz
Senior Member
 
Registered: Sep 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, 12: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 12:50 AM.
 
Old 04-27-2011, 12:52 AM   #40
micxz
Senior Member
 
Registered: Sep 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, 01: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 02:23 AM.
 
Old 04-27-2011, 07:42 AM   #42
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
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, 08: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, 08:24 PM   #44
micxz
Senior Member
 
Registered: Sep 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, 08: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



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 11:01 AM
how i can run bash script on my web? mikejosh Programming 2 04-09-2010 09: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 11:24 AM
How toExecute bash scripts from web interface milescook Linux - Software 3 05-28-2006 08:44 AM
Execute bash commands from web page solomage Linux - Software 1 10-07-2004 10:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:41 AM.

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
Open Source Consulting | Domain Registration