[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 125
  • Last Modified:

Bash Script Probleme with my variable

hello all

hi have a probleme with my bash my variable not works

files= ./home/files

  while read line           
do           
    python $files/adnplay.py $line           
done <$files/adnvideo.txt 
            break
            ;;

Open in new window


i need help
0
Gaaara
Asked:
Gaaara
  • 11
  • 5
  • 2
  • +1
4 Solutions
 
woolmilkporcCommented:
Omit the space and use quotes (optional):

files="./home/files"

Please keep in mind that the path "./home/files" is relative to the current working directory!

"break" and ";;" are in the wrong places, or did you post just a part of the script?
0
 
GaaaraAuthor Commented:
yes is a part of script :)

no is not work

http://pastebin.com/w53cfdHF
script
0
 
woolmilkporcCommented:
"no is not work" is a rude and discorteous but not a sufficient reaction to my suggestions.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
GaaaraAuthor Commented:
sorry my english is bad and I said that it did not work in the words which I know I did not want to be offend
0
 
woolmilkporcCommented:
It's not your English.  Just "it did not work" without any further explanation is not a bit better than your previous answer.
0
 
GaaaraAuthor Commented:
ah ok :)

i test your suggestions
my complete bash script
http://pastebin.com/w53cfdHF


files = "./files"

Open in new window


and i have a error

adnvideo.txt: No such file or directory

Open in new window


If the text is taken into the script it gives
python: can't open file 'adnplay.py': [Errno 2] No such file or directory
python: can't open file 'adnplay.py': [Errno 2] No such file or directory
python: can't open file 'adnplay.py': [Errno 2] No such file or directory
python: can't open file 'adnplay.py': [Errno 2] No such file or directory

Open in new window

0
 
woolmilkporcCommented:
I said "Omit the space", Why did you add spaces around the = sign" instead?

files="./files"
0
 
GaaaraAuthor Commented:
I removed the space and it gives the same thing

i execute the script in the home folder
and the folder "files" Is has the root of the script directory
0
 
GaaaraAuthor Commented:
... without variable it works ...
0
 
woolmilkporcCommented:
You're still aware that "." means "current directory", so that the path "./files" is relative to whatever directory you're in?
0
 
GaaaraAuthor Commented:
yes I know it  the "." is current directory  :)


      
why this line detect de files**$files/HD.py** ans my line in the loop not works
0
 
TintinCommented:
Add the following code just before your while loop:

if [ ! -f $files/adnplay.py ]
then
     echo "$files/adnplay.py does not exist or is not readable"
    exit 1
fi

Open in new window

0
 
GaaaraAuthor Commented:
i have this  
/adnplay.py does not exist or is not readable

Open in new window


the variable I think that the variable is blocked
	

#!/bin/bash
# Bash Menu Script Example

PS3='Please enter your choice: '
options=("Option 1" "Option 2" "Option 3" "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "Option 1")
           files="./files"
readable is ok 
break
            ;;
        "Option 2")
is not readable
            while read line           
do           
    python $files/adnplay.py $line           
done <$files/adnvideo.txt 
            break
            ;;
        "Option 3")
            echo "you chose choice 3"
            ;;
        "Quit")
            break
            ;;
        *) echo invalid option;;
    esac
done

Open in new window

0
 
ozoCommented:
files="./files" is set in "Option 1")
but $files/adnplay.py is used in "Option 2")
0
 
GaaaraAuthor Commented:
yes I did not know that it would work not in the others option thus solved
0
 
GaaaraAuthor Commented:
I've requested that this question be deleted for the following reason:


it is not necessary to continue :) thank you all for your help
0
 
TintinCommented:
gaaara had their problem solved with our help.   I suspect the language issue might be the reason they requested a delete.
0
 
GaaaraAuthor Commented:
i got the solution :)

I wrote the variable Outside the munu  it works
0
 
GaaaraAuthor Commented:
ty for your help  :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 11
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now