Tuesday, May 7, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 460  / 3 Years ago, wed, august 25, 2021, 7:41:41

I have a simple script which takes commands to start, stop, restart and return the status of a game server (SA:MP). The site provides the solution for using this command:



./samp03svr &


Which works all well and dandy however when the script executes this it holds and waits for user input (pressing ENTER) which then continues script execution.



I can't seem to find a way to keep the scripts execution without waiting for any user input. I've been searching for about 5 hours now and have tried at least 20 different things including running screen. Running screen worked just doesn't provide the exact thing I am looking for. The script also collects the process ID immediately after like so:



mv ./server_log.txt ./logs/server_$NOW.txt
mv ./mysql_log.txt ./logs/mysql_$NOW.txt
./samp03svr <<< echo &
pid=$!
echo $pid > $pidf
echo -e "The server has been started successfully"


The message that comes up waiting for RETURN is:



Started server on port: 7777, with maxplayers: 30 lanmode is OFF.


The server is running 64-bit Ubuntu 12.04.



Thanks in advance.


More From » bash

 Answers
6

Because samp03svr outputs text, you need to redirect the output to null



 ./samp03svr > /dev/null 2>&1 &

[#26246] Friday, August 27, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
skipu

Total Points: 366
Total Questions: 114
Total Answers: 112

Location: Saudi Arabia
Member since Mon, Sep 5, 2022
2 Years ago
skipu questions
Sun, Dec 26, 21, 05:25, 2 Years ago
Wed, Oct 6, 21, 10:26, 3 Years ago
Sun, Oct 31, 21, 02:01, 3 Years ago
Tue, Feb 14, 23, 19:48, 1 Year ago
;