Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi!
I have some TF2 servers running in a screen, now I want to create a little script that sends a specific text to all of these servers. Now finding the PID etc isn't a problem, more the sending text to process. How do I do that?
eg.
Code:
for PID in `pgrep -x srcds_run`; do $PID < "sm_reloadadmins\n"; done
Last edited by Gachl; 06-29-2009 at 04:57 AM.
Reason: changed example
Have the receiving process read the pipe; it will block waiting for the input. When data is written, the receiving process will read it and take whatever action is coded.
Well, I still have to write in the process itself
The TF2 server is basically a foreground application for the console where I can type commands and it executes it on the server (eg. I type status and it writes the current server status).
now if I use this:
Code:
./start_server_cp < serverfifo
I won't see any IO of the server's console.
edit: no thats wrong, the process simply stopps until something is in serverfifo..
This is WAY too complex..
Is there a way of mapping the stdin of a process to two sources, which would be in my case my keyboard and my named pipe? (And of course stdout to the console). And all this without blocking.
Good point.
I also could set my pipe as stdin and stdout and then use some kind of weird contraption of tee and tail -f to read+write the servers I/O.
But for some reason
Code:
./start_server_testing <> serverfifo
doesn't write the servers output to the serverfifo *confused*.
Edit: assuming multiple input sources are possible the process can mix the two because I am 1000% sure, if something writes to the pipe nothing is written to the console. So I think this wouldnt cause any trouble.
Edit2: Damn this can't be so hard to send text to a process. Linux is so powerful, this should be a damn small task for it
Edit2: Damn this can't be so hard to send text to a process. Linux is so powerful, this should be a damn small task for it
I did not attempt to understand the details, but the advice offered by @david1941 did not seem all that complex....In fact, I must go back and thank him for getting into my thick head what a "named pipe" is.....
I did not attempt to understand the details, but the advice offered by @david1941 did not seem all that complex....In fact, I must go back and thank him for getting into my thick head what a "named pipe" is.....
agree. But I don't want to run an additional script if I start the server just to get the pipe work.
Also why isn't program <> pipe writing stdout to the pipe? I still can see all console output and the pipe remains empty.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.