?
Solved

Bash Script  Probleme with my variable

Posted on 2015-01-15
20
Medium Priority
?
115 Views
Last Modified: 2015-01-21
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
Comment
Question by:Gaaara
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 5
  • 2
  • +1
20 Comments
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 668 total points
ID: 40551625
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
 

Author Comment

by:Gaaara
ID: 40551984
yes is a part of script :)

no is not work

http://pastebin.com/w53cfdHF
script
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40552013
"no is not work" is a rude and discorteous but not a sufficient reaction to my suggestions.
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:Gaaara
ID: 40552021
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
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40552045
It's not your English.  Just "it did not work" without any further explanation is not a bit better than your previous answer.
0
 

Author Comment

by:Gaaara
ID: 40552060
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
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40552132
I said "Omit the space", Why did you add spaces around the = sign" instead?

files="./files"
0
 

Author Comment

by:Gaaara
ID: 40552159
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
 

Author Comment

by:Gaaara
ID: 40552298
... without variable it works ...
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40552304
You're still aware that "." means "current directory", so that the path "./files" is relative to whatever directory you're in?
0
 

Author Comment

by:Gaaara
ID: 40552308
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
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 668 total points
ID: 40552344
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
 

Author Comment

by:Gaaara
ID: 40552561
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
 
LVL 84

Assisted Solution

by:ozo
ozo earned 664 total points
ID: 40552606
files="./files" is set in "Option 1")
but $files/adnplay.py is used in "Option 2")
0
 

Author Comment

by:Gaaara
ID: 40552621
yes I did not know that it would work not in the others option thus solved
0
 

Author Comment

by:Gaaara
ID: 40552729
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
 
LVL 48

Expert Comment

by:Tintin
ID: 40552730
gaaara had their problem solved with our help.   I suspect the language issue might be the reason they requested a delete.
0
 

Accepted Solution

by:
Gaaara earned 0 total points
ID: 40553932
i got the solution :)

I wrote the variable Outside the munu  it works
0
 

Author Closing Comment

by:Gaaara
ID: 40561589
ty for your help  :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question