0

Im kinda stuck here,

These are my codes

#script 1
#!/bin/bash
echo ""
$(ls -l)

#script 2
#!/bin/bash


echo ""
iwconfig

#script 3    
#!/bin/bash

PATH=$(pwd)

SC1=${PATH}/script1.sh 
SC2=${PATH}/script2.sh 

echo ""
read -p "Hi, whats your name? " NOME
echo ""
read -p "Glad to meet, ${NOME}, are you fine? [S/N] " FINE

funcao(){
    if [[ "${FINE}" = "S" || "${FINE}" = "s" ]]
    then    
        ${SC1} &
        wait
        echo -e "\nGreat, ${NOME}, me too!"
    elif [[ "${FINE}" = "N" || "${FINE}" = "n" ]]
    then
        ${SC2} &
        wait
        echo -e "\nAh, ${NOME}, thats sad :("
    else
        echo "Invalid answer, ${NOME}!"
    fi
}   


funcao

I don't know why it keep giving me this output

Output

What am i doing wrong?

Im just testing my skills, no need to be an important command, just need it to work.

Im new to linux, including shell/bash/etc.. Trying to learn, probably made some silly mistake... Well.... story of my life...

Thank you!

Barmar
  • 741,623
  • 53
  • 500
  • 612
creepohard
  • 3
  • 1
  • 1
  • 1
    Paste your output **as text**, not an image link. See https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors -- note screenshots are only acceptable *if the question is still clear and easy to understand without them*. Since your actual errors are only given behind the screenshot link, that doesn't apply here. (See https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557 for more discussion of why image links are frowned on) – Charles Duffy Dec 01 '17 at 01:46
  • Building a [mcve] -- the *shortest possible code that generates the same problem* -- is also a good step to follow before asking a question. – Charles Duffy Dec 01 '17 at 01:48
  • 1
    `$(ls -l)` is not correct. This will execute `ls -l`, then try to execute the output as a command. – Barmar Dec 01 '17 at 01:52

1 Answers1

1

At script 3 you are setting PATH. This variable determine where bash find the executables, by setting it you are preventing bash from finding ls binary so you got this error, use another name for that variable and you will be fine. Also check Shell variables section of manual for another special variables. https://linux.die.net/man/1/bash

geckos
  • 5,687
  • 1
  • 41
  • 53
  • Please don't link the ABS -- it's the W3Schools of bash, full of bad-practice examples and outdated information. – Charles Duffy Dec 01 '17 at 01:41
  • ...as opposed to just avoiding specific named variables, folks should follow [POSIX-recommended practice](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html) -- see fourth paragraph -- and use names with at least one lowercase character for their own variables, which avoids conflicts with both present and future versions of POSIX-specified tools. (The above link also specifies variable names that are explicitly reserved by POSIX). – Charles Duffy Dec 01 '17 at 01:42
  • This is also given in [the bash-hackers' wiki on syntax and coding guidelines](http://wiki.bash-hackers.org/scripting/style#syntax_and_coding_guidelines). – Charles Duffy Dec 01 '17 at 01:43
  • ...that said, if you *do* want a list of variables which are meaningful to bash specifically, for *that* the canonical reference is https://www.gnu.org/software/bash/manual/bashref.html#Shell-Variables – Charles Duffy Dec 01 '17 at 01:45
  • 2
    I removed the abs link and quoted the manual :). Thanks for pointing that out! – geckos Dec 01 '17 at 02:15