LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-26-2010, 07:20 PM   #1
hattori-hanzo
LQ Newbie
 
Registered: Dec 2010
Posts: 5

Rep: Reputation: 0
Which php command for shell interaction shall i use?


Hi

As homework for my study I have to do some kind of browser GUI to send commands to mysql command line tool and to show the output in the browser.

I already set up sudo to have the right permissions for the www-data user.

In the php documentation I found that one of the following four commands are probably for tasks like mine.

exec
passthru
shell exec
system

Can anyone tell me which one is the best for my requirements?

The idea is to use php from the browser to connect to mysql like on the command line with:
"mysql –user=username –password"
And then give back the output of the command line to the browser.

If the above is working then the next step would be to put a link in order to execute the command “show database;” again through php by clicking that link.
After clicking this link it would give back to the browser what the command line would display.

Thanks
Markus
 
Old 12-26-2010, 09:47 PM   #2
phpdba
LQ Newbie
 
Registered: Sep 2009
Distribution: OpenSuSE & Centos
Posts: 8

Rep: Reputation: 0
If you simply have to connect to mysql, why not use mysql_connect(host, user, password) and then mysql_select_db("name of db") and so on? Then you can use the mysql_error() command to generate the error you need from the connection. However, if you need to see actual command line output, I prefer exec, but that's me.
 
Old 12-27-2010, 03:03 AM   #3
hattori-hanzo
LQ Newbie
 
Registered: Dec 2010
Posts: 5

Original Poster
Rep: Reputation: 0
phpdba: Please read my whole posting. I'm study information technology and i have to do a homework for learning purpose.

Does anyone else have a recommendation on which php command i shall use for interaction of php with the mysql on the sell?
I was even think about to hack a little bit in the phpmyadmin scripts but my php knowhow is just not enough yet.

Thanks
Markus
 
Old 12-27-2010, 05:20 AM   #4
tshikose
Member
 
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 525

Rep: Reputation: 95
Hi,

The documentation of PHP is freely available from the web (http://www.php.net).
That said, the best way to connect to a MySQL database from PHP is what has been suggested to you by phpdba.

So now, you have a homework.
So do it your self!
Don't ask or expect others to do it for you.

Regards,

Tshimanga.
 
Old 12-27-2010, 05:41 AM   #5
hattori-hanzo
LQ Newbie
 
Registered: Dec 2010
Posts: 5

Original Poster
Rep: Reputation: 0
I was just expecting kind of an advice from a more advanced linux user to guide me in the right direction. My homework I will do myself, don’t worry about that;-)

To be honest, I don’t see the sense of your posting tshikose, or do you just want to increase your posting count?

bye
Markus
 
  


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
process interaction in shell script a.toraby Programming 10 11-09-2008 11:02 AM
PHP can't execute shell command ! rome Programming 3 11-15-2005 01:46 PM
PHP can't execute shell command ! rome Programming 1 11-15-2005 10:12 AM
shell script interaction sudhasmyle Linux - Software 1 12-08-2004 04:34 PM
Interaction in shell script sudhasmyle Programming 1 12-08-2004 08:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:37 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
Open Source Consulting | Domain Registration