1

This has driven me crazy so I hope someone can help. I have a script that works perfectly when executed manually or when restarting lightdm, but when it runs during a boot and auto-login, it returns a literal * instead of using it as a wildcard. It is set to run from

/home/pi/.config/lxsession/LXDE-pi/autostart

by including:

@/bin/sh /home/pi/finder.sh

the script includes:

fileName=( /media/pi/DISPLAY/display.* )
[[ -e $fileName ]]

I have used other iterations of code and search methods, but all have the same results. When this script is run under any circumstances other than a boot/login it returns a $fileName something like:

/media/pi/DISPLAY/display.txt

or

/media/pi/DISPLAY/display.ppt

However, when the pi boots and performs its auto-login, it returns the exact $fileName of:

/media/pi/DISPLAY/display.*

I have tried any number of alernative coding solutions, and even started with a simple find command. However, everything I do has the same results of working with:

./finder.sh
sudo systemctl restart lightdm

but nothing I have tried works during the normal boot process and always returns a literal * instead of wilcard results.

1
  • 1
    i'm only guessing here. it may be that the boot-time shell is different from run-time shell
    – jsotola
    Feb 25, 2018 at 5:28

2 Answers 2

1

The shell is run with turned-off globbing, most likely for "security reasons".

$ ls -1
a
b
$ echo *
a b
$ set -f
$ echo *
*
$ set +f
$ echo *
a b
$
0

You will get "/media/pi/DISPLAY/display.*" when there is no file corresponding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.