LinuxQuestions.org
Help answer threads with 0 replies.
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, 10: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 10:10 PM.
 
Old 04-20-2011, 11: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, 11:43 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 11,680
Blog Entries: 12

Rep: Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902
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-21-2011, 12:03 AM   #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-21-2011 at 12:11 AM.
 
Old 04-21-2011, 01: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, 09:57 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
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 10:32 AM.
 
Old 04-21-2011, 10: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, 10:31 AM   #8
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
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, 11: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, 11: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, 08: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, 09:09 AM   #12
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
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, 09: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, 09:20 AM   #14
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
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, 09: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


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 12:49 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