Skip to main content
added 552 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

Well, the man page does say stuff can't be used for large inputs:

stuff [string]

Stuff the string string in the input buffer of the current window. This is like the "paste" command but with much less overhead. [...] You cannot paste large buffers with the "stuff" command. It is most useful for key bindings.

But it does hint at paste:

paste [registers [dest_reg]]

Write the (concatenated) contents of the specified registers to the stdin queue of the current window. The register '.' is treated as the paste buffer.

readbuf [-e encoding] [filename]

Reads the contents of the specified file into the paste buffer. [...]

I tried it by pasting the screen man page (2600 lines, 166 kB) to an editor:

screen -S test -X readbuf /tmp/screen.txt
screen -S test -X paste .

and got the identical file back after saving it, so it seems paste might work better. This does have the downside of requiring more than one command, though, and I don't know if it can be done without passing the data through a file.

In any case, I'm not sure if pasting data through screen is the best way to send commands to a running server, but I don't know if Minecraft provides other ways to send commands than stdin.

One solution which I've seen done with another game server is to redirect input to the server from a pipe, like

tail -f inputfile | ./whateverserver ...

and then, if you need to issue commands to it, run echo some command >> inputfile. This should work similarly to stuffing input with screen.

Note that any solution like this that stuffs commands automatically to a single input has the problem that unless you're careful, multiple commands being sent at the same time may get mixed up. Really, this would need locking.

Well, the man page does say stuff can't be used for large inputs:

stuff [string]

Stuff the string string in the input buffer of the current window. This is like the "paste" command but with much less overhead. [...] You cannot paste large buffers with the "stuff" command. It is most useful for key bindings.

But it does hint at paste:

paste [registers [dest_reg]]

Write the (concatenated) contents of the specified registers to the stdin queue of the current window. The register '.' is treated as the paste buffer.

readbuf [-e encoding] [filename]

Reads the contents of the specified file into the paste buffer. [...]

I tried it by pasting the screen man page (2600 lines, 166 kB) to an editor:

screen -S test -X readbuf /tmp/screen.txt
screen -S test -X paste .

and got the identical file back after saving it, so it seems paste might work better. This does have the downside of requiring more than one command, though, and I don't know if it can be done without passing the data through a file.

In any case, I'm not sure if pasting data through screen is the best way to send commands to a running server, but I don't know if Minecraft provides other ways to send commands than stdin.

Well, the man page does say stuff can't be used for large inputs:

stuff [string]

Stuff the string string in the input buffer of the current window. This is like the "paste" command but with much less overhead. [...] You cannot paste large buffers with the "stuff" command. It is most useful for key bindings.

But it does hint at paste:

paste [registers [dest_reg]]

Write the (concatenated) contents of the specified registers to the stdin queue of the current window. The register '.' is treated as the paste buffer.

readbuf [-e encoding] [filename]

Reads the contents of the specified file into the paste buffer. [...]

I tried it by pasting the screen man page (2600 lines, 166 kB) to an editor:

screen -S test -X readbuf /tmp/screen.txt
screen -S test -X paste .

and got the identical file back after saving it, so it seems paste might work better. This does have the downside of requiring more than one command, though, and I don't know if it can be done without passing the data through a file.

In any case, I'm not sure if pasting data through screen is the best way to send commands to a running server, but I don't know if Minecraft provides other ways to send commands than stdin.

One solution which I've seen done with another game server is to redirect input to the server from a pipe, like

tail -f inputfile | ./whateverserver ...

and then, if you need to issue commands to it, run echo some command >> inputfile. This should work similarly to stuffing input with screen.

Note that any solution like this that stuffs commands automatically to a single input has the problem that unless you're careful, multiple commands being sent at the same time may get mixed up. Really, this would need locking.

Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

Well, the man page does say stuff can't be used for large inputs:

stuff [string]

Stuff the string string in the input buffer of the current window. This is like the "paste" command but with much less overhead. [...] You cannot paste large buffers with the "stuff" command. It is most useful for key bindings.

But it does hint at paste:

paste [registers [dest_reg]]

Write the (concatenated) contents of the specified registers to the stdin queue of the current window. The register '.' is treated as the paste buffer.

readbuf [-e encoding] [filename]

Reads the contents of the specified file into the paste buffer. [...]

I tried it by pasting the screen man page (2600 lines, 166 kB) to an editor:

screen -S test -X readbuf /tmp/screen.txt
screen -S test -X paste .

and got the identical file back after saving it, so it seems paste might work better. This does have the downside of requiring more than one command, though, and I don't know if it can be done without passing the data through a file.

In any case, I'm not sure if pasting data through screen is the best way to send commands to a running server, but I don't know if Minecraft provides other ways to send commands than stdin.