Solved

Bash Script  Probleme with my variable

Posted on 2015-01-15
20
93 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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 this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

13 Experts available now in Live!

Get 1:1 Help Now