LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-21-2012, 05:51 AM   #1
h3llkill3r
LQ Newbie
 
Registered: Oct 2009
Distribution: CentOS, Debian, Ubuntu
Posts: 18

Rep: Reputation: 0
starting gnu screen using php


I want to do a script to start an application using screen in php. The command to start the server is "screen ./tserver" in directory "/home/servers/". Anyone knows how I can exec that command using php. Thanks.
 
Old 01-21-2012, 03:40 PM   #2
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,434

Rep: Reputation: 110Reputation: 110
Apparently, you just need to run:

exec (screen ./tserver);

http://php.net/manual/en/function.exec.php

I haven't used PHP for many years, so I had to look it up.

May I give you some advice? When I used PHP, a long time ago, I was a computer/linux/programming newbie and didn't know any better. PHP was the only language that I knew, so I ventured into "shell scripting" with PHP. It was very good practice, but I eventually realized that it's hardly a good idea. There are many languages a lot more suitable to such tasks.

Happy coding!

Last edited by lucmove; 01-21-2012 at 03:41 PM.
 
Old 01-22-2012, 10:01 AM   #3
h3llkill3r
LQ Newbie
 
Registered: Oct 2009
Distribution: CentOS, Debian, Ubuntu
Posts: 18

Original Poster
Rep: Reputation: 0
so to start an application I use screen -d -m ./tserver and I made exec('screen -d -m ./tserver'); and tried with shell_exec too but it isn't working. When I replace screen -d -m ./tserver with exec(mkdir ('folder'));, it works.
 
  


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 automate starting a process in gnu screen and restart it when it crashes kav Linux - Server 6 09-12-2010 03:26 PM
unable to login root in starting gnu srinu.gmca07 Red Hat 14 12-16-2009 04:18 PM
trying to use GNU screen. backspace makes screen flash. twelvenine Linux - Software 5 08-07-2009 08:37 PM
installing screen(http://www.gnu.org/software/screen/) dreamlemon Solaris / OpenSolaris 5 09-29-2007 03:36 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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