LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-04-2009, 09:57 PM   #1
steve51184
Member
 
Registered: Dec 2006
Posts: 381

Rep: Reputation: 30
how do i use php to pass commands onto a server?


hi all how do i use php to pass commands onto a server?

like i want to be able to:

1. delete the content of a file (or just delete the file and make a new one if it's easier)

2. read the content from a file

3. write new data to a file via an input box

4. run a command on the server

any help would be really appreciated
 
Old 03-04-2009, 11:27 PM   #2
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
a tutorial on forms with php
http://www.phpf1.com/tutorial/php-form.html

php file i/o
http://www.felixgers.de/teaching/php/fileIO.html

as for running a command on the server perhaps the system() function, however that is a security hole
 
Old 03-05-2009, 12:02 AM   #3
steve51184
Member
 
Registered: Dec 2006
Posts: 381

Original Poster
Rep: Reputation: 30
the tutorial on forms with php and the php file i/o looks like what i need and about a security hole only i will have access to this php script so it'll be "safe" imo but please feel free to correct me (p.s. i have a dedicated server so only i have access to it)

will post here later with what i have to ether ask for more help or for others to use if needed

thank you
 
Old 03-05-2009, 12:50 AM   #4
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
if the script can be accessed via internet then it is possible that it could be potentially exploited, on second thought, what kind of 'dedicated server' is it and do you have root access to it?
 
Old 03-05-2009, 01:00 AM   #5
steve51184
Member
 
Registered: Dec 2006
Posts: 381

Original Poster
Rep: Reputation: 30
it's an amd 2.5ghz dual core, 4gb ram 320gb x2 VERY nice server and yes root access

also i'll be using a .htaccess like below:

Quote:
Order deny,allow
Deny from all
Allow from myip
so as you can see only i will be able to use it
 
Old 03-05-2009, 02:32 AM   #6
T74marcell
Member
 
Registered: Mar 2009
Posts: 102

Rep: Reputation: 18
1. delete the content of a file (or just delete the file and make a new one if it's easier)
unlink ($filename);
system ("echo \"\" > filename");

2. read the content from a file
$fp = fopen($filename, "r");
$string = fgets ($fp);

3. write new data to a file via an input box
the contents of the input box are passed via the POST or GET mechanism of the HTTP transfer
get the passed values like $_REQUEST['idname']
fwrite ($fp, $_REQUEST['idname'], strlen($_REQUEST['idname']));

4. run a command on the server
system ("echo \"\" > filename");


----------
T74marcell

Arch Linux

Last edited by T74marcell; 03-14-2009 at 12:53 AM.
 
Old 03-05-2009, 02:46 AM   #7
steve51184
Member
 
Registered: Dec 2006
Posts: 381

Original Poster
Rep: Reputation: 30
wow thanks T74marcell for answers 1,2,3 but if i wanted them in a php file with an option to select/do each one how would i do that without making them in there own script?

and for answer 4 can i do that with any command like system ("wget http://domain.com/file.zip");
 
Old 04-29-2009, 02:24 AM   #8
steve51184
Member
 
Registered: Dec 2006
Posts: 381

Original Poster
Rep: Reputation: 30
bump?
 
  


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
PHP - How can I pass stuff to includes? win32sux Programming 22 03-16-2008 01:01 PM
Adding users with PHP (pass php variables to Expect script) Jayla Programming 1 10-20-2006 10:44 AM
pass javascript variable to php ALInux Programming 6 01-06-2006 06:20 AM
PHP Pass Parameter Gerardoj Programming 2 05-25-2004 08:12 AM
How do I pass commands to the kernel? muxman Linux - General 2 05-18-2004 03:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:56 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