Jump to content

Create a button (Linux Command)


JoccE

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.