i'm using some bash command to extract the current teamviewer id.
Therefore i use this:
#!/bin/bash
OUTPUT="$(teamviewer --info | grep "TeamViewer ID:" | tr -s " " | cut -d ":" -f$
TEAMVIEWERID="${OUTPUT}"
echo $TEAMVIEWERID
mysql --host=xxx --user=xxx --password=xxx xxx$
update table SET teamviewerID="$TEAMVIEWERID" WHERE client="$1";
EOF
echo "DONE"
if i run it:
pi@xxx:~/Documents/xxx/tv $ sudo ./tv.sh client_xxx
4975XXXXX
DONE
pi@xxx:~/Documents/xxx/tv $
ok everything seems to be fine BUT in mysql i receive the following thing: [0m 4975XXXXX
I'm confused what is happening here...
thx for helping
The characters at the beginning ( [0m
) are a so called escape sequence.
This specific one is used to clear all terminal formattings.
You can easily strip it by using sed
.
Just replace your TEAMVIEWERID=
line with the following:
TEAMVIEWERID=$(echo "$OUTPUT" | sed 's/\[0m\s//g')
Edit : If the TeamViewer ID always consists of numbers only, we can strip the unknown character by only allowing numbers:
TEAMVIEWERID=$(echo "$id" | sed 's/\[0m\s//g' | sed -re 's/[^0-9]+//g')
This will only allow numbers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.