JoccE Posted January 7, 2013 Share Posted January 7, 2013 I've read and tried a lot now... But cant get it too work. In linux i use a command called "screen" most linux nerds out there know what that is. So what i want to make is a little button that If screen exist do "screen -r nameofscreen" if no screen with that name exist create one. and in that screen session it will run the commmand i have created. I have no idea if this is even possible but would be cool if any of you could fix it for me or give me some pointers. so a button that runs screen -r screenname in that screen do a linux command Thanks for your help JoccE Quote Link to comment https://forums.phpfreaks.com/topic/272801-create-a-button-linux-command/ Share on other sites More sharing options...
Christian F. Posted January 7, 2013 Share Posted January 7, 2013 The biggest question I have right now, is where do you want this button? It's quite trivial to make a bash script that does what you want, but I have no idea how you want to use it nor where this button of yours fits into the picture. Since I don't know that, I can't even tell you whether or not it's possible to even make a button in the first place. Quote Link to comment https://forums.phpfreaks.com/topic/272801-create-a-button-linux-command/#findComment-1403922 Share on other sites More sharing options...
JoccE Posted January 7, 2013 Author Share Posted January 7, 2013 I have created a basic login site where you will have 2 buttons One as the one i explained and one "panic button" that will just run a "killall" command incase you have too kill the application since its scripted too loop. it's nothing fancy i just want a button in the middle of the page (Slacker admin panel for myself) The button will trigger the command. Quote Link to comment https://forums.phpfreaks.com/topic/272801-create-a-button-linux-command/#findComment-1403925 Share on other sites More sharing options...
jazzman1 Posted January 7, 2013 Share Posted January 7, 2013 You can execute linux commands within a php script using a shell_exec - http://php.net/manual/en/function.shell-exec.php As Christian mentioned above it's quite easy to make a bash script which does this. Take a look at here, make sure that your Slackware has a web CGI library installed on it - http://www.yolinux.com/TUTORIALS/BashShellCgi.html Quote Link to comment https://forums.phpfreaks.com/topic/272801-create-a-button-linux-command/#findComment-1403956 Share on other sites More sharing options...
JoccE Posted January 8, 2013 Author Share Posted January 8, 2013 The problem is tho that i want to do it in a screen session. Since it is a running application. Quote Link to comment https://forums.phpfreaks.com/topic/272801-create-a-button-linux-command/#findComment-1404119 Share on other sites More sharing options...
Christian F. Posted January 8, 2013 Share Posted January 8, 2013 From the manpage for screen: at [identifier][#|*|%] command [args ... ] Execute a command at other displays or windows as if it had been entered there. "At" changes the context (the `current window' or `current display' setting) of the command. If the first parameter describes a non-unique context, the command will be executed mul‐ tiple times. If the first parameter is of the form `identifier*' then identifier is matched against user names. The command is executed once for each display of the selected user(s). If the first parameter is of the form `identifier%' identifier is matched against displays. Displays are named after the ttys they attach. The prefix `/dev/' or `/dev/tty' may be omitted from the identifier. If identifier has a `#' or nothing appended it is matched against window numbers and titles. Omitting an identifier in front of the `#', `*' or `%'-character selects all users, displays or windows because a prefix-match is performed. Note that on the affected display(s) a short message will describe what happened. Permission is checked for initiator of the "at" command, not for the owners of the affected display(s). Note that the '#' character works as a comment introducer when it is preceded by whitespace. This can be escaped by prefixing a '\'. Permission is checked for the initiator of the "at" command, not for the owners of the affected display(s). Caveat: When matching against windows, the command is executed at least once per window. Commands that change the internal arrangement of windows (like "other") may be called again. In shared windows the command will be repeated for each attached display. Beware, when issuing toggle commands like "login"! Some commands (e.g. "process") require that a display is associated with the target windows. These commands may not work correctly under "at" looping over windows. Quote Link to comment https://forums.phpfreaks.com/topic/272801-create-a-button-linux-command/#findComment-1404128 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.