Solved

how to get a informatin on a text files for my script

Posted on 2014-10-07
8
143 Views
Last Modified: 2014-10-08
Hello

is a script bash

my part of code
 -v -T '848444' -r "link1" -a "link2" -f "WIN 13,0,0,182" -W "yes.swf" -p "http://yoyo.com" -y "mp4:$src" -o "$name.mp4"

Open in new window


exemple text files
<meta base="link.com/blablabla.mp4"/></head><body><video src="link.com/blablabla" /></body>

Open in new window


I want to get the links between "" "" and copy to my code

exemple 2
get this link on the text files  "link.com/blablabla.mp4" (link 1)  "link.com/blablabla"  (link 2)

-v -T '848444' -r "link.com/blablabla.mp4" -a "link.com/blablabla" -f "WIN 13,0,0,182" -W "yes.swf" -p "http://yoyo.com" -y "mp4:$src" -o "$name.mp4"

Open in new window


and copie link on my code  without the "

tx :)
0
Comment
Question by:Gaaara
  • 4
  • 3
8 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 40367653
In the first example, where is the text file referenced?

In the second example, are links defined by the -a and -r arguments?
0
 

Author Comment

by:Gaaara
ID: 40367663
my code is an  example purposes only

I want to have that in between " " and copy in a  variable on my bash :)

exemple

is the text files

<meta base="link.com/blablabla.mp4"/></head><body><video src="link.com/blablabla" /></body> 

Open in new window


how to get information between " " on text files

and créate a variable on my bash

link1=link.com/blablabla.mp4
echo "$link1" 

link2=link.com/blablabla
echo "$link2"

Open in new window

0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 40367994
Are there always exactly two quoted strings in the relevant line of the text file?
Do these lines always contain a unique keyword, like e. g. "meta"?
And, most important: Is there just one line in the textfile containing that keyword?

If so you can try this:

links=$(sed  -n '/meta/s/^.*"\(.*\)".*"\(.*\)".*$/\1 \2/p' textfile)
link1=${links% *}
link2=${links#* }
echo $link1
echo $link2

Alternatively, use awk. This will work even if there is just one quoted string, but we'll need a check to avoid link1 and link2 being the same in that case:

links=$(awk -F\" '/meta/ {if($4=="") $4="dummy"; print $2, $4}' textfile)
link1=${links% *}
link2=${links#* }
[[ $link2 = "dummy" ]] && unset link2
echo $link1
echo $link2

If there are (can be) several lines in the textfile containing the keyword and the links we must create a loop and work with arrays instead of single variables.
0
 

Author Comment

by:Gaaara
ID: 40368808
did not work

Are there always exactly two quoted strings in the relevant line of the text file?  yes
Do these lines always contain a unique keyword, like e. g. "meta"? yes
And, most important: Is there just one line in the textfile containing that keyword? no

links always changes just some word that does not change
link1 rtmpe: // does not change
link2 mp4 does not change

<smil><head><meta base="rtmpe://yoyo.com/vod"/></head><body><video src="JPMAK9ytVw3fzAxHuweyyeuw3743434kn3j4huyd67cuj3nr$$%fjudfyDWIe9XM2BElbQ74JZnAHm5RYe3EUm5J9AmZdpeJdK78VaGdw%3D-p%2BdQbrgVg7oqPMKmM16KQw%3D%3D.mp4?audioindex=0" /></body></smil>
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40368946
Given the data you posted both of my scripts will show

for link1:
rtmpe://yoyo.com/vod

for link2:
PMAK9ytVw3fzAxHuweyyeuw3743434kn3j4huyd67cuj3nr$$%fjudfyDWIe9XM2BElbQ74JZnAHm5RYe3EUm5J9AmZdpeJdK78VaGdw%3D-p%2BdQbrgVg7oqPMKmM16KQw%3D%3D.mp4?audioindex=0

which exactly represents the two quoted strings which you asked to extract.

So why do you say "did not work" (apart from the fact that such a phrase is rude, at least extremely impolite)?
0
 

Author Comment

by:Gaaara
ID: 40369010
im so sorry ! it works

sorry I do not mean to be rude and it works I had made ​​a mistake

is a google translate and I do not speak english naturally
0
 

Author Closing Comment

by:Gaaara
ID: 40369012
nikel
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40369052
Merci a la pelle!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Centos Boot Error 42 111
null coming in rpm name 3 58
linux / python expert needed 3 79
Linux Search 3 64
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

17 Experts available now in Live!

Get 1:1 Help Now