<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=6892&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / [SOLVED] /etc/cron.hourly/somejob starts a bash script as dash]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=6892</link>
		<description><![CDATA[The most recent posts in [SOLVED] /etc/cron.hourly/somejob starts a bash script as dash.]]></description>
		<lastBuildDate>Mon, 13 Jan 2025 05:30:54 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: [SOLVED] /etc/cron.hourly/somejob starts a bash script as dash]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=54060#p54060</link>
			<description><![CDATA[<p>another option is to use an inline script as a function with a heredoc.</p><p>here&#039;s an example of what is a posix compliant shell script that wraps the program nsxiv to add functionality but since there&#039;s no good way to decode a uri to a path with just the core utils a simple python script is used from a function, this sort of thing can be done with any interpreter for any language, say you want an awk script or a perl script, even a bash script the process would be all the same.</p><div class="codebox"><pre class="vscroll"><code>#!/bin/sh

TMPDIR=&quot;${TMPDIR:-/tmp}&quot;
tmp=&quot;$TMPDIR/nsxiv_rifle_$$&quot;

is_img_extension() {
    grep -iE &#039;\.(jpe?g|png|gif|svg|jxl|webp|tiff|heif|avif|ico|bmp|pam|pbm|ppm|tga|qoi|ff|jpg_large)$&#039;
}

listfiles() {
    if [ -n &quot;$SORT_BY_TIME&quot; ]; then
    find -L &quot;$1&quot; -maxdepth 1 -type f -printf &#039;%T@\t%p\n&#039; |
        sort -n | cut -f2 | is_img_extension | tee &quot;$tmp&quot;
    else
    find -L &quot;$1&quot; -maxdepth 1 -type f -print |
        is_img_extension | sort -Vfd | tee &quot;$tmp&quot;
    fi
}

open_img() {
    file=&quot;$1&quot;; shift;
    # only go through listfiles() if the file has a valid img extension
    if echo &quot;$file&quot; | is_img_extension &gt;/dev/null 2&gt;&amp;1; then
        trap &#039;rm -f $tmp&#039; EXIT
        count=&quot;$(listfiles &quot;///${file%/*}&quot; | grep -nF &quot;$file&quot;)&quot;
    fi
    if [ -n &quot;$count&quot; ]; then
        nsxiv-env -i -n &quot;${count%%:*}&quot; &quot;$@&quot; -- &lt; &quot;$tmp&quot;
    else
        # fallback incase file didn&#039;t have a valid extension, or we couldn&#039;t
        # find it inside the list
        nsxiv-env &quot;$@&quot; -- &quot;$file&quot;
    fi
}

uri2path() {
    python3 - &quot;$@&quot; &lt;&lt;&#039;___HEREDOC&#039;
from urllib.parse import unquote, urlparse
from sys import argv
for arg in argv[1:]:
    print(unquote(urlparse(arg).path))
___HEREDOC
}

[ &quot;$1&quot; = &#039;--&#039; ] &amp;&amp; shift
case &quot;$1&quot; in
    &quot;&quot;) echo &quot;Usage: ${0##*/} PICTURES&quot; &gt;&amp;2; exit 1 ;;
    /*) open_img &quot;$1&quot; ;;
    &quot;~&quot;/*) open_img &quot;$HOME/${1#&quot;~&quot;/}&quot; ;;
    file:///*) open_img &quot;$(uri2path &quot;$1&quot;)&quot; ;;
    trash:///*)
        trash_dir=&quot;${XDG_DATA_HOME:-$HOME/.local/share}/Trash/files&quot;
        open_img &quot;${trash_dir}$(uri2path &quot;$1&quot;)&quot; -N &quot;nsxiv_trash&quot;
        ;;
    *) open_img &quot;$PWD/$1&quot; ;;
esac</code></pre></div><p>another option is to have sub-scripts that may live in library paths, something like /usr/local/lib/mycronscript/module and then you run that module from inside your script as another executable.</p>]]></description>
			<author><![CDATA[dummy@example.com (EDX-0)]]></author>
			<pubDate>Mon, 13 Jan 2025 05:30:54 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=54060#p54060</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] /etc/cron.hourly/somejob starts a bash script as dash]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=54049#p54049</link>
			<description><![CDATA[<p>If your working environment relies heavily on bash, you might consider replacing DASH with BASH as the default shell as I did.&#160; It &quot;just works&quot; and I&#039;ve had no cause to reconsider the decision :</p><div class="quotebox"><blockquote><div><p><strong>HOWTO : use bash instead of dash as the default shell in daedalus</strong><br /><a href="https://dev1galaxy.org/viewtopic.php?id=5753" rel="nofollow">https://dev1galaxy.org/viewtopic.php?id=5753</a></p></div></blockquote></div><p>Cheers,<br />--K</p>]]></description>
			<author><![CDATA[dummy@example.com (kaiyel)]]></author>
			<pubDate>Sun, 12 Jan 2025 18:18:09 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=54049#p54049</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] /etc/cron.hourly/somejob starts a bash script as dash]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=52813#p52813</link>
			<description><![CDATA[<p>It is not possible to set the shell for a particular task in /etc/cron.hourly, etc/cron.daily, etc/cron.weekly and /etc/cron.monthly. <br />Setting shell for all jobs is in /etc/default/cron.<br />I moved the job into the crontab (crontab -e) of root.<br />Now&#160; we go to the next problem.</p>]]></description>
			<author><![CDATA[dummy@example.com (bai4Iej2need)]]></author>
			<pubDate>Thu, 31 Oct 2024 22:15:53 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=52813#p52813</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] /etc/cron.hourly/somejob starts a bash script as dash]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=52789#p52789</link>
			<description><![CDATA[<p>Hi<br />I failed to explain that&#160; I have a protocol function in the script which writes to /var/log/somejob/somejob.log, if executed as root. <br />I verified now that the script starts indeed as a dash script instead of starting as bash. Some command inside requires a bashism and then the script fails.<br />Works as root !<br />I correct now the headline as well.</p>]]></description>
			<author><![CDATA[dummy@example.com (bai4Iej2need)]]></author>
			<pubDate>Mon, 28 Oct 2024 10:43:40 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=52789#p52789</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] /etc/cron.hourly/somejob starts a bash script as dash]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=52695#p52695</link>
			<description><![CDATA[<p>I&#039;m confused... perhaps because I don&#039;t know what &quot;the protocol log&quot; is or may be because you do not say if the log is produced when /etc/cron.hourly/somejob runs or when you start&#160; central_sync.bash&#160; manually</p><p>If I remember this correctly, cron does not know the environment you use in the terminal.&#160; That may explain the difference you observe, and possibly the parameter expansion problem.</p><p>Prove to yourself that /etc/cron.hourly/somejob is executable and that cron actually starts it.&#160; Study the output from set.&#160; Move on to locate what fails in /etc/cron.hourly/somejob</p><p>-- <br />OddS</p>]]></description>
			<author><![CDATA[dummy@example.com (OddS)]]></author>
			<pubDate>Sat, 19 Oct 2024 09:28:12 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=52695#p52695</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] /etc/cron.hourly/somejob starts a bash script as dash]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=52659#p52659</link>
			<description><![CDATA[<p>I have tested now several versions<br />Version 1</p><div class="codebox"><pre><code>head central_sync
#!/bin/bash
# synchronise Unlimited number of directories on different hosts
... </code></pre></div><p>central_sync is a hardlink to /usr/local/bin/central_sync.bash</p><p>version 2</p><div class="codebox"><pre><code>cat central_sync2
#!/bin/sh
set
/bin/bash /usr/local/bin/central_sync.bash

exit 0</code></pre></div><p>version 3</p><div class="codebox"><pre><code>cat central_sync3
#!/bin/sh
set
/bin/bash -x /usr/local/bin/central_sync.bash

exit 0</code></pre></div><p>version 4</p><div class="codebox"><pre><code>cat central_sync4
#!/bin/sh
set
/bin/bash --posix /usr/local/bin/central_sync.bash

exit 0</code></pre></div><p>They all produce in the protocol log:</p><div class="codebox"><pre><code>...
set 
...
SHELL=/bin/sh</code></pre></div><p>Consequently the program fails, which runs when called in the console/terminal<br />Parameter expansion fails in the rsync command</p>]]></description>
			<author><![CDATA[dummy@example.com (bai4Iej2need)]]></author>
			<pubDate>Thu, 17 Oct 2024 12:21:56 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=52659#p52659</guid>
		</item>
	</channel>
</rss>
