Reputation: 9
so I'm trying to use this command:
export DISPLAY=:1; /usr/bin/xterm -hold -e /path/to/shscript
Where shscript
is:
#!/bin/bash
echo "Restarting ... $(date)" >> /var/log/mw2.txt
if screen -ls | grep -q 'test'; then
screen -X -S test quit
sleep 1000
screen -d -m -S test wine iw4m.exe -dedicated -console +dw_licensefile license.dat +set net_port "28960" +set party_maxplayers 18 +exec server.cfg +map_rotate +set fs_game "mods/tsd"
else
screen -d -m -S test wine iw4m.exe -dedicated -console +dw_licensefile license.dat +set net_port "28960" +set party_maxplayers 18 +exec server.cfg +map_rotate +set fs_game "mods/tsd"
fi
So I want to launch a new xterm window and it to run a shell script. But whatever shell script I try to use, it doesn't run it. It just goes blank. All other commands work, but when I put a shell script in it, it just goes blank and does nothing. I can't find a solution for this, please help, thank you.
I get this with set -x
:
++ date
+ echo 'Restarting ... (date)'
+ grep -q test
+ screen -ls
+ screen -d -m -S test -wine iw4m etc...
Upvotes: 0
Views: 1365
Reputation: 9
Yep. It was the wine
command failing. I changed some stuff, and it works now. I had to put cd /home/MW2
in the script for it to be able to run the iw4m.exe, then screen -S etc.
Upvotes: 0
Reputation: 973
I think you get exactly what you have asked for...
From screen's man page:
-d -m Start screen in "detached" mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts.
On the other hand you use -hold for xterm:
-hold Turn on the hold resource, i.e., xterm will not immediately destroy its window when the shell command completes. It will wait until you use the window manager to destroy/kill the win‐ dow, or if you use the menu entries that send a signal, e.g., HUP or KILL.
And that's exactly what you see. xterm starts, executes screen which runs, but you don't see the output as screen does not attach to the virtual terminal. Since screen has detached the shell script exits and xterm holds the window for you to destroy it at your leisure.
I bet that if in another xterm you attach to the session with screen -S test
you'll see the output.
Upvotes: 0