"Autostart script gets 'no such file or directory' error despite files existing"

"Hello, I am trying to set up a thin client to autostart an internet radio stream on boot. I have done the following steps:

  1. Installed DietPi to a USB drive.

  2. Created an autostart script named radio-stream.sh in the /var/lib/dietpi-autostart/ directory.

  3. Configured dietpi-autostart to use a custom script with autologin.

However, upon reboot, the system gives the error ‘no such file or directory’. I have performed multiple diagnostic checks and the problem persists.

Here is the output of my diagnostic commands:

Output of ls -l /var/lib/dietpi-autostart/: custom.sh radio-stream.sh

Output of cat /var/lib/dietpi-autostart/custom.sh:

#!/bin/bash
/var/lib/dietpi-autostart/radio-stream.sh
exit 0

Output of cat /var/lib/dietpi-autostart/radio-stream.sh:

#!/usr/bin/env bash
while true
do
  cvlc --play-and-exit "https://stream.amfm.link:8010/kjm"
  sleep 10
done

Can you please advise on why the system would be giving this error when the file clearly exists? Thank you for your help."

Why using 2 files? Did you tried to copy content from radio-stream.sh into custom.sh?

1 Like

I think I did. Sorry. Not really familiar with this OS. I am only trying to make use of the unit I have. It’s a DELL Wyse 2GB SSD and 2GB RAM.

I hope you can help me get it to start and work.

Copy this content into /var/lib/dietpi-autostart/custom.sh

Und use the full path instead command only

1 Like

Hello,

Thank you for your excellent guidance so far. Your instructions were successful in getting the script to run and bypass all the previous errors.

The custom.sh script is now running on boot, but I am facing a new and very specific error with the audio output. It seems to be a problem with the ALSA device.

The system gives the error: “Audio output failed The audio device “hw:0,0” could not be used: No such file or directory” and “Cannot open ALSA device ‘hw:0,0’: No such file in the directory”.

Here is the code in my custom.sh file, which is based on your last instructions:

#!/usr/bin/env bash

while true
do
    /usr/bin/cvlc --aout=alsa --alsa-audio-device=hw:0,0 --play-and-exit "https://stream.amfm.link:8010/kjm"
    sleep 10
done

It seems that the hw:0,0 device is not correct on my system. Can you please advise on how to find the correct ALSA device, or why the system would report that hw:0,0 does not exist?

Thank you for your help.

Hello,

Thank you so much for your initial guidance. I am happy to report that the issue is now completely solved.

The problem turned out to be a combination of two things: a file path issue and a VLC configuration problem. Your advice to use a single script was the key that got us on the right path.

The main issue was that the dietpi-autostart process was looking in a different directory for the script than where I had created it.

Here is the final, working script that is in my /var/lib/dietpi/dietpi-autostart/custom.sh file. It addresses the file path issue, the VLC permissions, and the specific audio device on my unit:

Bash

#!/usr/bin/env bash

while true
do
    /usr/bin/cvlc --aout=alsa --alsa-audio-device=plughw:SB,0 -I dummy --play-and-exit --quiet "https://stream.amfm.link:8010/kjm"
    sleep 10
done

Thank you again for your help and for setting me on the right track. This project is now fully functional.

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