Last active
April 8, 2019 03:29
Star
You must be signed in to star a gist
Clean up remained xrdp socket files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SOCKDIR=/tmp/.xrdp | |
SESSIONS=$(cd ${SOCKDIR} ; ls -1 xrdp_* | sed -e 's|[^0-9]||g' | sort -u) | |
for i in ${SESSIONS} | |
do | |
if [ ! -S ${SOCKDIR}/xrdp_display_${i} ] | |
then | |
( | |
cd ${SOCKDIR} | |
rm -f xrdp_chansrv_audio_in_socket_${i} \ | |
xrdp_chansrv_audio_out_socket_${i} \ | |
xrdp_chansrv_socket_${i} \ | |
xrdpapi_${i} | |
) | |
fi | |
done |
#!/bin/sh
SOCKDIR=/tmp/.xrdp
SESSIONS=$cd ${SOCKDIR} ; ls -1 xrdp_* | sed -e 's|[^0-9]||g' | sort -u
for i in ${SESSIONS}
do
if [ ! -S ${SOCKDIR}/xrdp_display_${i} ]
then
(
cd ${SOCKDIR}
rm -f xrdp_chansrv_audio_in_socket_${i} \
xrdp_chansrv_audio_out_socket_${i} \
xrdp_chansrv_socket_${i} \
xrdpapi_${i}
)
fi
done
In this version of the error, "Missing" does not occur. There is another error - "Permission denied". Run the script like this: sudo sh xrdp_clean_sockets.sh
The script doesn't do bashisms. It should work with /bin/sh
.
The SESSIONS line can be written like this.
# space after first "("
SESSIONS=$( (cd ${SOCKDIR} ; ls -1 xrdp_*) | sed -e 's|[^0-9]||g' | sort -u)
# actually "( )" surrounding ls and cd is not necessary
SESSIONS=$(cd ${SOCKDIR} ; ls -1 xrdp_* | sed -e 's|[^0-9]||g' | sort -u)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:-(
then your code works https://www.tutorialspoint.com/execute_bash_online.php (bash v4.4)
On my PC the Bash v4.3 and there is an error: Syntax error: Missing '))'