
Il 19/12/20 14:18, David Haller ha scritto:
Hello,
On Sat, 19 Dec 2020, Marco Calistri wrote:
Il 19/12/20 12:42, David Haller ha scritto:
exec 1>>"$OSRF" Is not working here,
I want to use this syntax but it is returning error:
#!/bin/sh OSRF="/home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt" #>>"$OSRF" printf "Marco Calistri\n" >> "$OSRF" printf "Build:$(head -n 1 /etc/issue|awk -F'to' '{print $2}'|awk -F'-' '{print $1}')" >> "$OSRF" printf "Kernel:$(uname -r)" >> "$OSRF" printf "Desktop:$(rpm -q --qf XFCE (%{version})\n -f /usr/bin/xfce4-session"
"$OSRF" I have not (it seems) exec installed on my system so I commented the cleaning exec >>"$OSRF" 'exec' is a shell-builtin, and the cleaning is done the line above by the '>"$OSRF"' (which outputs "nothing" into the file).
When I test the script it returns the error (translated from Italian):
/etc/cron.hourly/sig-os-release: riga 7: EOF not expected during the search of """ /etc/cron.hourly/sig-os-release: riga 8: syntax error: EOF not expected You got a missing " somewhere. And mind you, you should not use printf as you use echo!
#!/bin/sh OSRF="/home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt" OK.
#>>"$OSRF" That'd be appending, not "nulling" the output file, use >"$OSRF" (just one '>' in front of the filename (variable).
printf "Marco Calistri\n" >> "$OSRF" ok.
printf "Build:$(head -n 1 /etc/issue|awk -F'to' '{print $2}'|awk -F'-' '{print $1}')" >> "$OSRF" If you must:
printf 'Build: %s\n' \ "$(head -n 1 /etc/issue | awk -F'to' '{print $2}' | \ awk -F'-' '{print $1}')"
But see my version with rpm/parsing of os-release!
printf "Kernel:$(uname -r)" >> "$OSRF" ok.
printf "Desktop:$(rpm -q --qf XFCE (%{version})\n -f /usr/bin/xfce4-session">>> "$OSRF" ^^^^^^^^^^^^^^^^^^^^^^ you're missing quotes here around the format argument for --qf for rpm! *BADUMM* *tssss*
Just use the script I proposed!
==== #!/bin/bash OSRF="/home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt"
"$OSRF" ### clear file exec 1>>"$OSRF"
printf 'Marco Calistri\n' rpm -q --qf 'Build: openSUSE Tumbleweed %{version}\n' -f /etc/os-release printf 'Kernel: %s\n' "$(uname -r)" rpm -q --qf 'Desktop: XFCE (%{version})\n' -f /usr/bin/xfce4-session ====
It does work! No matter if XFCE is or is not running!
*hrmpf*, -dnh
Yeah, I'm very bad on this especially when I'm in hurry! Thanks, one day I will succeed! ;-) Best regards, -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel:5.9.14-1-default