[Solved] Is there any restriction on the 'nested level/depth' of shell script?

Hi.

I'm calling series of nested shell script when transmission completed as
'transmission completion.sh > script1.sh > script2.sh > script3.sh > execuable binary'.
Is this anything wrong? since the script3.sh never calling.

No, there is no hardcoded limit.

really? erm... then....what is the cause of the symptom...
event first line of 3rd script never ran(for debug like 'echo "test" >> /var/test.log' which non of string printed)...
so weird...what should be the test or fix procedure?

This is impossible to answer without knowing more context. My guess is that there's a problem in one of your scripts. Maybe you implicitly rely on environment which is available when interactively testing scripts but not when called from transmission.

Erm...well...the reason why asking is that

  • those series of script are work fine when called from another daemon.
  • the 1st script.sh working fine when called from command line.
    So weird huh? That is why I'm asking....
    sigh....any......idea to test whether this kind of.....symptom??

And each of script have 3~4 of arguments to pass over to next script.

...until you are out of RAM. Which can happen pretty quick on a 32 MB system; each instance of ash takes more than a MB.

huh? good to know...
my system has 1 GB swap file on external SSD, doesn't it helpful??
(my device is WRT32x but tons of service running on the device..ftp, webdav, samba, dlna, etc)

Hi, All.

I have found the cause of the symptom(as jow and other people mentioned that not the script depth issue. lol).
below command line in a script not worked when its called from Transmission daemon.

#!/bin/sh
nice flock -n /var/run/email_send_core_engine.lock -c "/etc/email_send_core_engine_inner.sh \"$1\" \"$2\" \"$3\" \"$4\"" &
  • What would make difference of the behavior of the 'flock' command when it called from Transmission? (other system daemon not make any trouble with them,)
  • What would be the workaround (or solution) to use same functionality in the shell script?
  • Should I raise the symptom as an issue to the OpenWrt developer who in charge of flock??

What other system daemons use flock? For that matter, why do you have a four-script deep thread to run something that is supposedly a daemon?

What functionality do you think it's performing. Ostensibly, you have a single instance of transmission running, so you'll only have a single instance of each of the scripts. From that, the flock executable doesn't seem like it is doing anything useful at all.

  • That being four scripts are to keep consistency of other process's usage since the script is old one multiply used.
  • As I mentioned above, the script used from multiple different process simultaneously.

So, any answer for my question?

Question again,

  • What would make difference of the behavior of the 'flock' command when it called from Transmission? (other system daemon not make any trouble with them,)
  • What would be the workaround (or solution) to use same functionality in the shell script?
  • Should I raise the symptom as an issue to the OpenWrt developer who in charge of flock??

Some ideas:

Wrong PATH in the environment when launched from by transmission
Headless usage
Launched as non-root user without permissions

And note that flock is provided by busybox

Thanks!

Will figure it out the launch configuration with having some time.
And if there is no workaround or solution,
will go to busybox people.

Have a good day.

The cause of issue was that

  • The transmission runs as the account 'transmission' which is not a root.
  • 'flock' command need, seem that as a result, root permission.

To solve main issue of this article,

  • Put/add 'sudo' command in the script series when call some of command in script.
  • Add sudo permission into the account 'transmission' to allowing it by 'sudoers' file.

Solved!

Thanks hnyman. You giving me insight everytime.
Have a gooday all.

flock -n /var/run/email_send_core_engine.lock
drwxr-xr-x    4 root     root           400 Dec 13 09:15 /var/run

Perhaps better and more secure would be creating a transmission-specific run-time directory (likely at boot, changing its ownership to the transmission user and group).

There's many good reasons why transmission is not run as a privileged user.

Thanks for the tip. That would be great. Will consider it later for the script folder and lock file folder both.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.