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-20-2011, 09:03 PM   #1
athrin
Member
 
Registered: Mar 2011
Posts: 135

Rep: Reputation: 1
bash from web


hi,

can i ask you guys something. is this code can be run through webpage?
i want serial file to be auto generate when user run the webpage and not with sh code.
Code:
dmidecode | grep Number > /var/www/cgi-bin/serial
i have tried by putting sh example.sh code inside example.sh file but it doesnt work.
can someone tell me on how to auto generate serial file through webpage if this code is wrong.

thanks,
Athrin

Last edited by athrin; 04-20-2011 at 09:10 PM.
 
Old 04-20-2011, 10:11 PM   #2
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
err.. is it hard to understand or this question just to hard??

emmm..
what i want is, when i run this example.sh script through website and it will auto create a another file called serial. inside that file contain serial number. that all.
 
Old 04-20-2011, 10:43 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,335
Blog Entries: 28

Rep: Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144
I know of no way to make HTML run a bash script, but I'm hardly a guru.

Perhaps if you explain what end result or output you want, as opposed to one way you are trying to produce that end result, someone could help you.
 
Old 04-20-2011, 11:03 PM   #4
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
errr...
i want to display my serial number using web browser. i have my php code that will ask user to put some name like example. and that name will be shown with serial number like this.

enter name:______


name : athrin.
serial: xxxxxx

the problem is the serial wont show. i already tried to do this code
Code:
dmidecode | grep Number > /var/www/cgi-bin/serial
by sending the serial to another file and in my bash will call the file by using "cat". but it still not showing, i want my serial to be shown. do you have any idea on how to do that?

Last edited by athrin; 04-20-2011 at 11:11 PM.
 
Old 04-21-2011, 12:51 AM   #5
rahulkya
Member
 
Registered: Feb 2009
Location: New Delhi
Distribution: Linux mint,Ubuntu,Debian,RHEL 5,slackware 13.1, free BSD,solaris.
Posts: 186
Blog Entries: 3

Rep: Reputation: 33
you cannot run dmidecode by browser it will say permission denied .. If u already saved your serial number in a file u can always display it through webpage ..PHP can do it..The following code will work
Quote:
echo `cat /var/www/cgi-bin/serial`;
In the above quote note that to make your linux command work you have to use above command...
u can show your linux command in web-browser by
Quote:
echo `your linux command here`
hope this works for you
 
Old 04-21-2011, 08:57 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
SO you want the output of a bash command to appear inside an HTML page?

How are you executing the command? Seems like doing it via PHP, Perl, Python, or another server-side scripting language would be the only way.

Last edited by MTK358; 04-21-2011 at 09:32 AM.
 
Old 04-21-2011, 09:22 AM   #7
rahulkya
Member
 
Registered: Feb 2009
Location: New Delhi
Distribution: Linux mint,Ubuntu,Debian,RHEL 5,slackware 13.1, free BSD,solaris.
Posts: 186
Blog Entries: 3

Rep: Reputation: 33
Quote:
Originally Posted by MTK358 View Post
SO you want the output of a bash command to appear inside an HTML page?

How are you executing the command? Seems like doing it via PHP would be the only way.
No almost every server side scripting language has inbuilt functions to make system calls..
PHP has two or three methods to do that ,one of them is above ...
 
Old 04-21-2011, 09:31 AM   #8
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I know that PHP isn't the only scripting language that can do it, I just said it that way since PHP was what the OP is using. I'll edit my post to clear up the confusion.
 
Old 04-21-2011, 10:17 PM   #9
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by rahulkya View Post
you cannot run dmidecode by browser it will say permission denied .. If u already saved your serial number in a file u can always display it through webpage ..PHP can do it..The following code will work


In the above quote note that to make your linux command work you have to use above command...
u can show your linux command in web-browser by

hope this works for you
i know it will work but only work with serial, name will not be display
 
Old 04-21-2011, 10:23 PM   #10
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by MTK358 View Post
SO you want the output of a bash command to appear inside an HTML page?

How are you executing the command? Seems like doing it via PHP, Perl, Python, or another server-side scripting language would be the only way.
i'm execute command with php. other command like view ip addrs or ram works but serial doesnt work.
 
Old 04-22-2011, 07:58 AM   #11
rahulkya
Member
 
Registered: Feb 2009
Location: New Delhi
Distribution: Linux mint,Ubuntu,Debian,RHEL 5,slackware 13.1, free BSD,solaris.
Posts: 186
Blog Entries: 3

Rep: Reputation: 33
Quote:
Originally Posted by athrin View Post
i'm execute command with php. other command like view ip addrs or ram works but serial doesnt work.
I think there is problem with permissions....dmidecode can run only by root or sudoers..
 
Old 04-22-2011, 08:09 AM   #12
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by rahulkya View Post
I think there is problem with permissions....dmidecode can run only by root or sudoers..
If so, you can make sudo run the dmidecode command for a certain user without asking for a password. Run visudo and add this line:

Code:
username ALL = NOPASSWD: path-to-dmidecode-executable
 
Old 04-22-2011, 08:12 AM   #13
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
What about using a cron job that builds runs the dmidecode command and redirects it output into a file inside your webserver directory?
 
Old 04-22-2011, 08:20 AM   #14
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by zhjim View Post
What about using a cron job that builds runs the dmidecode command and redirects it output into a file inside your webserver directory?
Seems like that way the page will not always be up to date.
 
Old 04-22-2011, 08:32 AM   #15
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by MTK358 View Post
Seems like that way the page will not always be up to date.
Your probably right, I forget that the info of dmidecode changes so fast.
 
  


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:23 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