cron job signatures script
Hello, (Note: This is a generic Linux/Unix question not specifically related to Opensuse) Here a weird fact I face running a cron job from /etc/cron.hourly which it looks to trim away the final part of the text I aim to get. Below is the signature generated by script I add into the cron job: -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop: Whereas here at the bottom the same script result if I run it from my console: -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop: (Xfce 4.14) <----------------As you can see the script ran by the cron job it is missing this part. I suppose it could be caused by some variables settings which are different from my user environment and the ones used by the cron user. This is the script I use: #!/bin/sh echo "Marco Calistri" > /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Build: $(head -n 1 /etc/issue|awk -F'to' '{print $2}'|awk -F'-' '{print $1}')" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Kernel: $(uname -r)" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Desktop:$(xfce4-session --version |awk -F'xfce4-session' '{print $2}'|awk -F'2' '{print $2}')" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo -ne "\n" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt Thanks for any eventual suggestion you could provide to me. Regards, Marco
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday, 2020-12-18 at 13:19 -0300, Marco Calistri wrote:
Hello,
(Note: This is a generic Linux/Unix question not specifically related to Opensuse)
Here a weird fact I face running a cron job from /etc/cron.hourly which it looks to trim away the final part of the text I aim to get.
Below is the signature generated by script I add into the cron job:
--
Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop:
Whereas here at the bottom the same script result if I run it from my console:
-- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop: (Xfce 4.14) <----------------As you can see the script ran by the cron job it is missing this part.
I suppose it could be caused by some variables settings which are different from my user environment and the ones used by the cron user.
This is the script I use:
#!/bin/sh echo "Marco Calistri" > /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Build: $(head -n 1 /etc/issue|awk -F'to' '{print $2}'|awk -F'-' '{print $1}')" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Kernel: $(uname -r)" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Desktop:$(xfce4-session --version |awk -F'xfce4-session' '{print $2}'|awk -F'2' '{print $2}')" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo -ne "\n" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt
Thanks for any eventual suggestion you could provide to me.
When I run the last but one line in my terminal I get: cer@Telcontar:~> echo "Desktop:$(xfce4-session --version |awk -F'xfce4-session' '{print $2}'|awk -F'2' '{print $2}')" Desktop:.1 (Xfce 4.1 cer@Telcontar:~> which is not what you say you get. I tried also as root, as your cronjob runs as root: Telcontar:~ # echo "Desktop:$(xfce4-session --version |awk -F'xfce4-session' '{print $2}'|awk -F'2' '{print $2}')" Desktop:.1 (Xfce 4.1 Telcontar:~ # I I run tests to try to see what sections of that line produce, they fail on me. As I can not read awk, I can't do much. But I can produce the same result. cer@Telcontar:~> xfce4-session --version | grep xfce4-session | cut -d" " -f3,4 (Xfce 4.12) cer@Telcontar:~> echo -n "Desktop: " >> file echo "xfce4-session --version | grep xfce4-session | cut -d" " -f3,4" >> file or VERSION=`xfce4-session --version | grep xfce4-session | cut -d" " -f3,4"` echo "Desktop: $VERSION" >> file or VERSION=`xfce4-session --version | head -1 | cut -d" " -f3,4` echo "Desktop: $VERSION" >> file - -- Cheers, Carlos E. R. (from openSUSE 15.1 x86_64 at Telcontar) -----BEGIN PGP SIGNATURE----- iHoEARECADoWIQQZEb51mJKK1KpcU/W1MxgcbY1H1QUCX90CVhwccm9iaW4ubGlz dGFzQHRlbGVmb25pY2EubmV0AAoJELUzGBxtjUfVUWgAnja5O+Yp7OI88LU9YTjG bmELnhU9AKCOpv47+2U4E/O1JaocLyYsh6rl6g== =sxFb -----END PGP SIGNATURE-----
Il 18/12/20 16:26, Carlos E. R. ha scritto:
echo "Desktop:$(xfce4-session --version |awk -F'xfce4-session' '{print $2}'|awk -F'2' '{print $2}')" Desktop:.1 (Xfce 4.1 cer@Telcontar:~>
Using bash in my env, may be its is the reason: marco@linux-turion64:~> env SHELL=/bin/bash -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop:
On 18/12/2020 20.50, Marco Calistri wrote:
Il 18/12/20 16:26, Carlos E. R. ha scritto:
echo "Desktop:$(xfce4-session --version |awk -F'xfce4-session' '{print $2}'|awk -F'2' '{print $2}')" Desktop:.1 (Xfce 4.1 cer@Telcontar:~>
Using bash in my env, may be its is the reason:
marco@linux-turion64:~> env SHELL=/bin/bash
cer@Telcontar:~> env | grep SHELL SHELL=/bin/bash cer@Telcontar:~> -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)
On Fri, Dec 18, 2020 at 01:19:41PM -0300, Marco Calistri wrote:
Hello,
(Note: This is a generic Linux/Unix question not specifically related to Opensuse)
Here a weird fact I face running a cron job from /etc/cron.hourly which it looks to trim away the final part of the text I aim to get.
Below is the signature generated by script I add into the cron job:
Try running your script with s cleared environment and a new non-login shell: env - /bin/sh /etc/cron.hourly/myjob
--
Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop:
Whereas here at the bottom the same script result if I run it from my console:
-- Marco Calistri Build:?? openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop: (Xfce 4.14)?????? <----------------As you can see the script ran by the cron job it is missing this part.
I suppose it could be caused by some variables settings which are different from my user environment and the ones used by the cron user.
This is the script I use:
#!/bin/sh echo "Marco Calistri" > /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Build: $(head -n 1 /etc/issue|awk -F'to' '{print $2}'|awk -F'-' '{print $1}')"?? >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Kernel: $(uname -r)" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Desktop:$(xfce4-session --version |awk -F'xfce4-session' '{print $2}'|awk -F'2' '{print $2}')"?? >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo -ne "\n" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt
Thanks for any eventual suggestion you could provide to me.
Regards,
Marco _______________________________________________ openSUSE Support mailing list -- support@lists.opensuse.org To unsubscribe, email support-leave@lists.opensuse.org List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette List Archives: https://lists.opensuse.org/archives/list/support@lists.opensuse.org
-- Brian Reichert <reichert@numachi.com> BSD admin/developer at large
Il 18/12/20 16:40, Brian Reichert ha scritto:
Below is the signature generated by script I add into the cron job: Try running your script with s cleared environment and a new non-login shell:
env - /bin/sh /etc/cron.hourly/myjob
I've not understood what you mean with "new non-login shell". Have I to found out a system user which has not a login shell? Or it is sufficient I simply run such command sequence on my own user shell? But the point is how to force cron to not trim out a part of the text I expect to write in the text file. Sorry and thanks for your response. -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop:
On 18/12/2020 23.21, Marco Calistri wrote:
Il 18/12/20 16:40, Brian Reichert ha scritto:
Below is the signature generated by script I add into the cron job: Try running your script with s cleared environment and a new non-login shell:
env - /bin/sh /etc/cron.hourly/myjob
You could use /bin/bash. Why sh? Do the change in your script, too.
I've not understood what you mean with "new non-login shell".
Google "what is a login shell in linux?" A login shell is a shell given to a user upon login into their user account. ... The general cases for having a login shell include: Accessing your computer remotely using ssh. Simulating an initial login shell with bash -l or sh -l. Simulating an initial root login shell with sudo -i. help.gnome.org › users › stable › pref-login-shell.html.en Login shells <https://help.gnome.org/users/gnome-terminal/stable/pref-login-shell.html.en> Google "what is a non-login shell in linux?" When a shell runs a script or a command passed on its command line, it's a non-interactive, non-login shell. Such shells run all the time: it's very common that when a program calls another program, it really runs a tiny script in a shell to invoke that other program. unix.stackexchange.com › questions › difference-between.. Difference between Login Shell and Non-Login Shell? - Unix ... <https://unix.stackexchange.com/questions/38175/difference-between-login-shell-and-non-login-shell>
Have I to found out a system user which has not a login shell?
Or it is sufficient I simply run such command sequence on my own user shell?
But the point is how to force cron to not trim out a part of the text I expect to write in the text file.
Precisely. The idea is to run the script in the same environment cron will use, to find out what the problem is. -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)
Il 18/12/20 19:46, Carlos E. R. ha scritto:
But the point is how to force cron to not trim out a part of the text I expect to write in the text file. Precisely. The idea is to run the script in the same environment cron will use, to find out what the problem is. Yes exactly is what I would need!
And regarding all the googling directions I say thanks but I had no time nor will to read it today. I've tried to replace "on the fly" the xfce version string of my original script using your which uses cut and it's look not good as per new signature below. Cheers, -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel:5.9.14-1-default Desktop:aprire il --help' per
On 19/12/2020 00.19, Marco Calistri wrote:
Il 18/12/20 19:46, Carlos E. R. ha scritto:
But the point is how to force cron to not trim out a part of the text I expect to write in the text file. Precisely. The idea is to run the script in the same environment cron will use, to find out what the problem is. Yes exactly is what I would need!
And regarding all the googling directions I say thanks but I had no time nor will to read it today.
I've tried to replace "on the fly" the xfce version string of my original script using your which uses cut and it's look not good as per new signature below.
Well, there must be a different "env" which affects it. I would play would the script triggered from a cron every minute till I got it right. It is just a debug and repeat problem. -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)
Il 18/12/20 23:13, Carlos E. R. ha scritto:
I've tried to replace "on the fly" the xfce version string of my original script using your which uses cut and it's look not good as per new signature below. Well, there must be a different "env" which affects it.
I would play would the script triggered from a cron every minute till I got it right. It is just a debug and repeat problem.
...Really boring troubleshooting: a system executed script that want to "play differently" of the same piece of strings played by a normal user... :-/ 8-) Oh my God! Look below! Something has changed at the end :-) -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel:5.9.14-1-default (Xfce 4.14) Desktop: (Xfce 4.14)
On 19/12/2020 15.29, Marco Calistri wrote:
Il 18/12/20 23:13, Carlos E. R. ha scritto:
I've tried to replace "on the fly" the xfce version string of my original script using your which uses cut and it's look not good as per new signature below. Well, there must be a different "env" which affects it.
I would play would the script triggered from a cron every minute till I got it right. It is just a debug and repeat problem.
...Really boring troubleshooting: a system executed script that want to "play differently" of the same piece of strings played by a normal user... :-/
BUt cron jobs DO play differently than the same thing done as a user. It is a characteristic, it is perfectly known. We told you, the environment is different.
8-) Oh my God! Look below! Something has changed at the end :-)
-- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)
Il 19/12/20 14:07, Carlos E. R. ha scritto:
I would play would the script triggered from a cron every minute till I got it right. It is just a debug and repeat problem.
...Really boring troubleshooting: a system executed script that want to "play differently" of the same piece of strings played by a normal user... :-/ BUt cron jobs DO play differently than the same thing done as a user. It is a characteristic, it is perfectly known. We told you, the environment is different.
Yes but it keeps to be BORING :-/ -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel:5.9.14-1-default
On Fri, Dec 18, 2020 at 07:21:24PM -0300, Marco Calistri wrote:
Il 18/12/20 16:40, Brian Reichert ha scritto:
Below is the signature generated by script I add into the cron job: Try running your script with s cleared environment and a new non-login shell:
env - /bin/sh /etc/cron.hourly/myjob
I've not understood what you mean with "new non-login shell".
What I meant was that your shell, when you are running that script, is a login shell, and when you've logged in all sorts of magic has fired to set up your environment, configure shell macros, alter your PATH, etc. Look at the man pagwefor bash, under the section named 'INVOCATION'. (Now that I'm reading it myself, 'interactive' also fires extra logic.) The point is, a shell script invoked by cron has a shell with a different configuration that you having interavively logged into your host.
Sorry and thanks for your response.
-- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop:
-- Brian Reichert <reichert@numachi.com> BSD admin/developer at large
Il 19/12/20 17:28, Brian Reichert ha scritto:
On Fri, Dec 18, 2020 at 07:21:24PM -0300, Marco Calistri wrote:
Il 18/12/20 16:40, Brian Reichert ha scritto:
Below is the signature generated by script I add into the cron job: Try running your script with s cleared environment and a new non-login shell:
env - /bin/sh /etc/cron.hourly/myjob
I've not understood what you mean with "new non-login shell". What I meant was that your shell, when you are running that script, is a login shell, and when you've logged in all sorts of magic has fired to set up your environment, configure shell macros, alter your PATH, etc.
Look at the man pagwefor bash, under the section named 'INVOCATION'.
(Now that I'm reading it myself, 'interactive' also fires extra logic.)
The point is, a shell script invoked by cron has a shell with a different configuration that you having interavively logged into your host.
Got it! Regards, -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel:5.9.14-1-default
Il 18/12/20 16:40, Brian Reichert ha scritto:
Below is the signature generated by script I add into the cron job: Try running your script with s cleared environment and a new non-login shell:
env - /bin/sh /etc/cron.hourly/myjob
Marco@linux-turion64:~> env - /bin/sh /etc/cron.hourly/sig-os-release Unable to init server: Could not connect: Connection refused -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop:
On Fri, Dec 18, 2020 at 07:27:08PM -0300, Marco Calistri wrote:
Il 18/12/20 16:40, Brian Reichert ha scritto:
Below is the signature generated by script I add into the cron job: Try running your script with s cleared environment and a new non-login shell:
env - /bin/sh /etc/cron.hourly/myjob
Marco@linux-turion64:~> env - /bin/sh /etc/cron.hourly/sig-os-release
Unable to init server: Could not connect: Connection refused
I did not retain a copy of your original script. Clearly, though, your script relies on some pre-established aspect of your environment. Cron's default path is, I think, '/usr/bin:/bin'. You can test-fire a script with a similar environment, e.g.: $ env - PATH=/usr/bin:/bin /usr/bin/printenv PATH=/usr/bin:/bin So, instead try your script like this: env - PATH=/usr/bin:/bin /bin/sh /etc/cron.hourly/sig-os-release
-- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop:
-- Brian Reichert <reichert@numachi.com> BSD admin/developer at large
Hello, On Fri, 18 Dec 2020, Marco Calistri wrote:
(Note: This is a generic Linux/Unix question not specifically related to Opensuse)
Here a weird fact I face running a cron job from /etc/cron.hourly which it looks to trim away the final part of the text I aim to get.
Below is the signature generated by script I add into the cron job:
--
Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop:
Whereas here at the bottom the same script result if I run it from my console:
-- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel: 5.9.14-1-default Desktop: (Xfce 4.14) <----------------As you can see the script ran by the cron job it is missing this part.
I suppose it could be caused by some variables settings which are different from my user environment and the ones used by the cron user.
This is the script I use:
#!/bin/sh echo "Marco Calistri" > /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Build: $(head -n 1 /etc/issue|awk -F'to' '{print $2}'|awk -F'-' '{print $1}')" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Kernel: $(uname -r)" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo "Desktop:$(xfce4-session --version |awk -F'xfce4-session' '{print $2}'|awk -F'2' '{print $2}')" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt echo -ne "\n" >> /home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt
First of all: your /bin/sh is probably bash anyway, so use it. But IIRC the following is POSIX compatible as well. a) you should use printf instead of echo b) if all you do is append stuff to a file you have 3 ways: 1) use a variable for the filename #!/bin/bash OSRF="/home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt" printf "...\n" >"$OSRF" printf "...\n" >>"$OSRF" .... 2) use a block #!/bin/bash OSRF="/home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt" { printf "...\n" printf "...\n" .... } >"$OSRF" 3) use exec OSRF="/home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt" >"$OSRF" # exec 1>>"$OSRF" printf "...\n" printf "...\n" .... c) there's nothing you can't do with just one awk that you do with two d) for your problem running an X program from cron there's a nice workaround: rpm -q --queryformat 'Desktop: XFCE (%{version})\n' \ -f /usr/bin/xfce4-session (short form of '--queryformat' is '--qf' (with '--'), '-qf' is '-q -f' and something quite different (and also used here ;) In summary: ==== #!/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 ==== For the "Build" line, you could also parse os-release: awk -F'[="]' '/PRETTY/{pn=$3;}/VERSION_ID/{v=$3;} END { printf("Build: %s %s\n", pn, v); }' /etc/os-release or eval /etc/os-release for the "Build" line (UNSAFE): eval "$(</etc/os-release)" printf 'Build: %s %s\n' "$PRETTY_NAME" "$VERSION_ID" None of this is in any way dependent on the env, so should run with or without X and XFCE even running. HTH, -dnh -- Zack Allan: "It just doesn't make any sense." Sheridan: "If you're gonna wait for the universe to start making sense you'll have a *long* wait ahead of you." -- Babylon 5 - 4x12 - Conflicts of Interest
Il 19/12/20 12:42, David Haller ha scritto:
In summary:
==== #!/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)"
/etc/cron.hourly/sig-os-release
====
For the "Build" line, you could also parse os-release:
awk -F'[="]' '/PRETTY/{pn=$3;}/VERSION_ID/{v=$3;} END { printf("Build: %s %s\n", pn, v); }' /etc/os-release
or eval /etc/os-release for the "Build" line (UNSAFE):
eval "$(</etc/os-release)" printf 'Build: %s %s\n' "$PRETTY_NAME" "$VERSION_ID"
None of this is in any way dependent on the env, so should run with or without X and XFCE even running.
HTH, -dnh Very good stuff ! Many thanks, as you could understand I'm not a shell or worst a programmer expert, so many times I get stuck trying to "invent" new coding/scripting" :-P
Regards, -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel:5.9.14-1-default Desktop:
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 --
Tell me again why you would want to emulate Paris Hilton? -- jeff shultz To be blond, rich, and have a nice rack? -- dima
Il 19/12/20 14:18, David Haller ha scritto:
Hello,
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
On Sat, 19 Dec 2020, Marco Calistri wrote: 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
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:
/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). Yes I knew about this to nulling files content the exec is present regularly but the exec 1 didn't worked here!
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 "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! I'm a kinda "mountain man" which obstinately insists on his errors! My updated script is this below, it works if I executed from my user shell, let's see what Mr. cron will do...
"$OSRF"
"$OSRF"
#!/bin/sh OSRF="/home/marco/.thunderbird/cy71896h.Marco/signatures/os-release.txt" printf "Marco Calistri\n" >> "$OSRF" printf "Build:$(head -n 1 /etc/issue|awk -F'to' '{print $2}'|awk -F'-' '{print $1}')\n" >> "$OSRF" printf "Kernel:$(uname -r)\n" >> "$OSRF" #printf "Desktop:$(rpm -q XFCE (%{version}) -f /usr/bin/xfce4-sessio)\n" printf "Desktop:$(xfce4-session --version |awk -F'xfce4-session' '{print $2}'|awk -F'2' '{print $2}')\n" >> "$OSRF" Cheers, -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel:5.9.14-1-default Desktop: (Xfce 4.14)
Hello, On Sat, 19 Dec 2020, Carlos E. R. wrote:
David, you are sending twice to the same list.
You send to support@lists.opensuse.org and opensuse-support@opensuse.org, which are the same thing.
I know. Marco sent to 'opensuse-support@opensuse.org' and my mutt honored that while also sending to the configured list support@lists.o.o. Happens only occasionally. And I don't always catch it before sending. Sorry about that. -dnh -- Outside Context Problem (OCP), the kind of problem "most civilisations would encounter just once, and which they tended to encounter rather in the same way a sentence encountered a full stop." -- Iain M. Banks, in a Culture novel
On 19/12/2020 18.53, David Haller wrote:
Hello,
On Sat, 19 Dec 2020, Carlos E. R. wrote:
David, you are sending twice to the same list.
You send to support@lists.opensuse.org and opensuse-support@opensuse.org, which are the same thing.
I know. Marco sent to 'opensuse-support@opensuse.org' and my mutt honored that while also sending to the configured list support@lists.o.o. Happens only occasionally. And I don't always catch it before sending. Sorry about that.
Ah, I see - no problem then :-) -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)
Il 19/12/20 14:53, David Haller ha scritto:
Hello,
On Sat, 19 Dec 2020, Carlos E. R. wrote:
David, you are sending twice to the same list.
You send to support@lists.opensuse.org and opensuse-support@opensuse.org, which are the same thing. I know. Marco sent to 'opensuse-support@opensuse.org' and my mutt honored that while also sending to the configured list support@lists.o.o. Happens only occasionally. And I don't always catch it before sending. Sorry about that.
-dnh
Why maillist admin keeps two different addresses active? He should disable one IMHO! KISS = Keep It Simple Stupid :-P -- Marco Calistri Build: openSUSE Tumbleweed 20201216 Kernel:5.9.14-1-default
On 19/12/2020 22.33, Marco Calistri wrote:
Il 19/12/20 14:53, David Haller ha scritto:
Hello,
On Sat, 19 Dec 2020, Carlos E. R. wrote:
David, you are sending twice to the same list.
You send to support@lists.opensuse.org and opensuse-support@opensuse.org, which are the same thing. I know. Marco sent to 'opensuse-support@opensuse.org' and my mutt honored that while also sending to the configured list support@lists.o.o. Happens only occasionally. And I don't always catch it before sending. Sorry about that.
Why maillist admin keeps two different addresses active? He should disable one IMHO!
KISS = Keep It Simple Stupid :-P
No, that would be disastrous. Millions of people have the old address saved, you would piss them a lot if that address would bounce. We try to cause minimal disturbation and damage. -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)
participants (5)
-
Brian Reichert
-
Carlos E. R.
-
Carlos E.R.
-
David Haller
-
Marco Calistri