staging.inyokaproject.org

bash: ./set.sh: Datei oder Verzeichnis nicht gefunden

Status: Gelöst | Ubuntu-Version: Ubuntu GNOME 18.04 (Bionic Beaver)
Antworten |

RainerZufall2

Anmeldungsdatum:
19. Mai 2020

Beiträge: Zähle...

Hallo,

wenn ich das Terminal starte, bekomme ich seit neustem folgende Zeile als erstes ausgegeben:

bash: ./set.sh: Datei oder Verzeichnis nicht gefunden

Nach einem

reset 

kommt diese Meldung nicht mehr.

Warum will die Shell das Skript set.sh ausführen?

seahawk1986

Anmeldungsdatum:
27. Oktober 2006

Beiträge: 11278

Vermutlich weil es in einer der Dateien steht, deren Code beim Starten der Shell-Session ausgeführt bzw. gesourced wird (z.B. ~/.bashrc. ~/.profile usw.).

reset starte die Shell-Session nicht komplett neu, sondern versucht nur das Terminal wieder in einen definierten Zustand zu bringen (vgl. https://manpages.ubuntu.com/manpages/bionic/man1/reset.1.html).

RainerZufall2

(Themenstarter)

Anmeldungsdatum:
19. Mai 2020

Beiträge: Zähle...

Vielen Dank.

In der ~/.bashrc stand der Eintrag ./set.sh. Wie bist du darauf gekommen? Oder: Wo kann man so etwas nachlesen? Bzw. wie geht man vor, wenn man wissen will, wo der Code steht, der beim Starten eines Programms ausgeführt wird? Nochmals Dankeschön.

seahawk1986

Anmeldungsdatum:
27. Oktober 2006

Beiträge: 11278

RainerZufall2 schrieb:

In der ~/.bashrc stand der Eintrag ./set.sh. Wie bist du darauf gekommen?

Wie so oft kommt man mit einer Kombination aus über die Jahre erworbenem Wissen (es hilft schon, wenn man weiß, wo man nachsehen muss) und Deduktion recht weit.

Oder: Wo kann man so etwas nachlesen?

Hier im Wiki gibt es einen eigenen Artikel zum Thema: Bash/bashrc (der sich nicht groß um das warum kümmert), außerdem steht das im info Manual, das man für die Bash aufrufen kann:

info bash 

Im Abschnitt INVOCATION kann man dann lesen, was da für eine interaktive bzw. eine Login-Shell alles passiert:

INVOCATION
       A login shell is one whose first character of argument zero is a -, or one started with the --login option.

       An interactive shell is one started without non-option arguments (unless -s is specified) and without  the  -c
       option  whose  standard  input  and error are both connected to terminals (as determined by isatty(3)), or one
       started with the -i option.  PS1 is set and $- includes i if bash is interactive, allowing a shell script or a
       startup file to test this state.

       The  following  paragraphs describe how bash executes its startup files.  If any of the files exist but cannot
       be read, bash reports an error.  Tildes are expanded in filenames as described below under Tilde Expansion  in
       the EXPANSION section.

       When  bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it
       first reads and executes commands from the file /etc/profile, if that file exists.  After reading  that  file,
       it  looks  for  ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands
       from the first one that exists and is readable.  The --noprofile option may be used when the shell is  started
       to inhibit this behavior.

       When  an  interactive  login  shell exits, or a non-interactive login shell executes the exit builtin command,
       bash reads and executes commands from the file ~/.bash_logout, if it exists.

       When an interactive shell that is not a login  shell  is  started,  bash  reads  and  executes  commands  from
       /etc/bash.bashrc  and ~/.bashrc, if these files exist.  This may be inhibited by using the --norc option.  The
       --rcfile file option will force bash to read and execute commands from file instead  of  /etc/bash.bashrc  and
       ~/.bashrc.
[...]

Bzw. wie geht man vor, wenn man wissen will, wo der Code steht, der beim Starten eines Programms ausgeführt wird?

Bei Open Source Software hat man generell die Möglichkeit im Quellcode nachzusehen - das kann aber zeitraubend und lästig sein, wenn man die verwendete Programmiersprache nicht beherrscht oder der Code zu umfangreich ist - daher würde ich nach Möglichkeit erst mal einen Blick ins Handbuch oder sonstige verfügbare Dokumentation werfen - für die Bash steht das z.B. auch in https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Bash-Startup-Files, dass beim Start als interaktive Shell die Datei ~/.profile gelesen und der darin enthaltene Code ausgeführt wird. Wenn man sich die Datei ansieht, weiß man, dass die Datei dafür sorgt, dass das gleiche mit der Datei ~/.bashrc passiert (die Funktion von einem frei stehenden Punkt ( . ) wird in https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#Bourne-Shell-Builtins erklärt.

Antworten |