Solved

Bash Script  Probleme with my variable

Posted on 2015-01-15
20
95 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
  • 11
  • 5
  • 2
  • +1
20 Comments
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 167 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 167 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 166 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
improve Shell script 5 145
what are these modules in perl script 4 94
Replace a tag with sed 2 47
replace column/record content in a *csv file based on a regular expression 6 53
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…
Utilizing an array to gracefully append to a list of EmailAddresses
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

861 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now