User avatar
pi-anazazi
Posts: 1020
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

systemctl broken - "syntax error near unexpected token..."

Sat Nov 21, 2020 5:49 pm

Hello again!

We have here a robot from an old school project with some years hanging around in the network

Code: Select all

uname -a
Linux brickberrypi 4.9.35+ #1014 Fri Jun 30 14:34:49 BST 2017 armv6l GNU/Linux
that recently had a strange LED blinking (don't remember the details) and needed a hard shutdown (no ssh reachable, GPIOs blocked by a hat for connecting Lego mindstorms hardware).

After fsck the machine rebooted and is accessible via ssh, but has some strange "features" when it comes to systemctl commands:

Code: Select all

# systemctl
/bin/systemctl: line 8: syntax error near unexpected token `$'\343\001\001\376\365\324i??\253\3077\267\307"\311\354\334\030yQ\244\362\032M\231\262>u\363\327`\004\3546\324\320P"\203\'\276\244\b\035g\353#e1\215\205lk\216(\037\361\211 \204y^??\251\036\261\023j\0069\301??s\340\026u\275\377n}\253\244`\001\001\307\341u\253\360P\331\362\346-\245\034+T:\207\252Z\212A\204<1??"C\217\262\241.LW\272B\205\001\001F\276\233\326n\2247\271''
/bin/systemctl: line 8: `I??0??sj??g??~??T??A??q??????????\??J????-??]???$????1??g1????G??Jh??{??^#????????)O/??C'??????jt$??h????]????????(????????i??????7????"????????yQ??????M????>u????`??6????P"??'??g??#e1????lk??(???? ??y^??????j9????s??u????n}????`????u????P??????-??+T:????Z??A??<1??"C??????.LW??B??F??????n??7??'
or, another example

Code: Select all

# shutdown -h now
/sbin/shutdown: line 8: syntax error near unexpected token `$'\343\001\001\376\365\324i??\253\3077\267\307"\311\354\334\030yQ\244\362\032M\231\262>u\363\327`\004\3546\324\320P"\203\'\276\244\b\035g\353#e1\215\205lk\216(\037\361\211 \204y^??\251\036\261\023j\0069\301??s\340\026u\275\377n}\253\244`\001\001\307\341u\253\360P\331\362\346-\245\034+T:\207\252Z\212A\204<1??"C\217\262\241.LW\272B\205\001\001F\276\233\326n\2247\271''
/sbin/shutdown: line 8: `I??0??sj??g??~??T??A??q??????????\??J????-??]???$????1??g1????G??Jh??{??^#????????)O/??C'??????jt$??h????]????????(????????i??????7????"????????yQ??????M????>u????`??6????P"??'??g??#e1????lk??(???? ??y^??????j9????s??u????n}????`????u????P??????-??+T:????Z??A??<1??"C??????.LW??B??F??????n??7??'
or

Code: Select all

$ sudo shutdown -h now
/sbin/shutdown: 1: /sbin/shutdown: Syntax error: Unterminated quoted string


Any ideas (besides a corrupted SD-card?) what's going on here?
Kind regards

anazazi

cleverca22
Posts: 4926
Joined: Sat Aug 18, 2012 2:33 pm

Re: systemctl broken - "syntax error near unexpected token..."

Sat Nov 21, 2020 7:00 pm

what do these commands return?

Code: Select all

ls -l /bin/systemctl /sbin/shutdown
file /bin/systemctl /sbin/shutdown

trejan
Posts: 3866
Joined: Tue Jul 02, 2019 2:28 pm

Re: systemctl broken - "syntax error near unexpected token..."

Sat Nov 21, 2020 7:10 pm

It is a corrupted card. Not much else would cause those errors. Saving what you can and reinstalling with a fresh image is your best option.

cleverca22
Posts: 4926
Joined: Sat Aug 18, 2012 2:33 pm

Re: systemctl broken - "syntax error near unexpected token..."

Sat Nov 21, 2020 7:11 pm

jojopi wrote:
Tue Nov 17, 2020 11:34 pm
evanshaw wrote:
Tue Nov 17, 2020 7:29 pm
And then tried a reinstall of all packages associated with curl, openssl, arm-linux-gnueabihf and libgcc, in case of corruption.
I think you are on the right track there. Try using debsums to check your entire system:

Code: Select all

sudo apt install debsums
sudo debsums -c
The second command should take a few minutes and produce no output unless it finds corrupt files.
(openssl won't actually download using apt to reinstall)
Not sure what you mean by that. Neither curl nor openssl appear to be dependencies for apt itself.
it looks like you can also use debsums to detect the corrupt files and then just reinstall them

User avatar
pi-anazazi
Posts: 1020
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: systemctl broken - "syntax error near unexpected token..."

Sun Nov 22, 2020 10:25 am

Hi and thanks for reply!

I have here:

Code: Select all

$ ls -l /bin/systemctl /sbin/shutdown
-rwxr-xr-x 1 root root 509836 May  7  2017 /bin/systemctl
lrwxrwxrwx 1 root root     14 May  7  2017 /sbin/shutdown -> /bin/systemctl
and

Code: Select all

ile /bin/systemctl /sbin/shutdown
/bin/systemctl: data
/sbin/shutdown: symbolic link to /bin/systemctl
How to proceed? :-)

PS: I did a

Code: Select all

sudo debsums -c
/bin/stty
/bin/ss
/usr/lib/debug/lib/arm-linux-gnueabihf/libc-2.19.so
/opt/vc/include/IL/OMX_Broadcom.h
/lib/modules/4.9.35+/kernel/drivers/hwmon/ina2xx.ko
/bin/systemctl
/bin/systemd-ask-password
debsums: missing file /lib/udev/rules.d/75-persistent-net-generator.rules.distrib (from udev package)
Should I try to re-install these packages? But the system is quite old (Jessie), are these packages still available?
Kind regards

anazazi

User avatar
pi-anazazi
Posts: 1020
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: systemctl broken - "syntax error near unexpected token..."

Sun Nov 22, 2020 11:09 am

OK, I reinstalled systemd and then I had

Code: Select all

sudo debsums -c
/bin/stty
/bin/ss
/usr/lib/debug/lib/arm-linux-gnueabihf/libc-2.19.so
/opt/vc/include/IL/OMX_Broadcom.h
/lib/modules/4.9.35+/kernel/drivers/hwmon/ina2xx.ko
debsums: missing file /lib/udev/rules.d/75-persistent-net-generator.rules.distrib (from udev package)
afterwards I went ahead and started a full-upgrade (247 old Jessie packages...)

As no essential packages appear to be damaged, it should go smooth. Will report after reboot :-)
Kind regards

anazazi

User avatar
pi-anazazi
Posts: 1020
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: systemctl broken - "syntax error near unexpected token..."

Sun Nov 22, 2020 1:35 pm

...had to install

Code: Select all

sudo apt-get install apt-file
to find the source packages for some damaged files, but after a round of reinstalls the debsum -c comes back empty. Will dd the SD-card now over to a fresh one and see how it runs in the future (just as an experiment, production systems would get a fresh install now ;-)...

Many thanks for helpful input!
Kind regards

anazazi

Return to “Troubleshooting”