Script reading from file and send to firefox


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script reading from file and send to firefox
# 8  
Old 02-28-2013
Make sure you have each line starting with an asterisk * and not any other character.

Also put an asterisk after character class [[:blank:]] to check zero or more occurrence:
Code:
[[ "$line" =~ ^\*[[:blank:]]*server1.com ]] && url_s1=${line##*: }

This User Gave Thanks to Yoda For This Post:
# 9  
Old 02-28-2013
sorry didnt work. can you please test it?

10x again!!
# 10  
Old 02-28-2013
It works for me!

It should be something to do with your input file. Can you post few lines from your original input file in code tags ?
This User Gave Thanks to Yoda For This Post:
# 11  
Old 02-28-2013
my 1.txt file looks like this exactly:


* server1.ux.com : ppup,ppyp,pop
---------------------------------

* server2.ux.com : pppup,pp,pippp
---------------------------------

* server3.ux.com : pp,pooppp,ppp
---------------------------------



Code:
while read line
do
        [[ "$line" =~ ^\*[[:blank:]]*server1.ux.com ]] && url_s1=${line##*: }
        [[ "$line" =~ ^\*[[:blank:]]*server2.ux.com ]] && url_s2=${line##*: }
        [[ "$line" =~ ^\*[[:blank:]]*server3.ux.com ]] && url_s3=${line##*: }
done < 1.txt

{
        echo -n "firefox http://"
        for U in ${url_s1//,/ }
        do
                printf "${U}&2C"
        done
        echo ".com/index.html"

        echo -n "firefox http://"
        for U in ${url_s2//,/ }
        do
                printf "${U}&2C"
        done
        echo ".com/index.html"

        echo -n "firefox http://"
        for U in ${url_s3//,/ }
        do
                printf "${U}&2C"
        done
        echo ".com/index.html"
} > output2.txt

---------- Post updated at 09:55 AM ---------- Previous update was at 09:46 AM ----------

can you try it?

Last edited by zigizag; 02-28-2013 at 11:07 AM..
# 12  
Old 02-28-2013
OK, if this is your input file then simply match urls. Replace existing with:
Code:
while read line
do
        [[ "$line" =~ server1\.ux\.com ]] && url_s1=${line##*: }
        [[ "$line" =~ server2\.ux\.com ]] && url_s2=${line##*: }
        [[ "$line" =~ server3\.ux\.com ]] && url_s3=${line##*: }
done < 1.txt

This User Gave Thanks to Yoda For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh Script, Reading A File, Grepping A File Contents In Another File

So I'm stumped. First... APOLOGIES... my work is offline in an office that has zero internet connectivity, as required by our client. If need be, I could print out my script attempts and retype them here. But on the off chance... here goes. I have a text file (file_source) of terms, each line... (3 Replies)
Discussion started by: Brusimm
3 Replies

2. UNIX for Dummies Questions & Answers

Reading XML file and print the values in the text file using Linux shell script

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (1 Reply)
Discussion started by: sravanreddy
1 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Reading Array And Send An Email

I am trying to find an example for reading an array instead of reading a file and send out an email in ksh. Can you please help is that possible? Algorithm #!/bin/ksh i=0 set -A ARR if then let i=$ ARR="A does n't match with B" fi if then let i=$ ARR="P does n't match with Q"... (11 Replies)
Discussion started by: Ariean
11 Replies

4. Shell Programming and Scripting

Bash script to send lines of file to new file based on Regex

I have a file that looks like this: cat includes CORP-CRASHTEST-BU e:\crashplan\ CORP-TEST /usr/openv/java /usr/openv/logs /usr/openv/man CORP-LABS_TEST /usr/openv/java /usr/openv/logs /usr/openv/man What I want to do is make three new files with just those selections. So the three... (4 Replies)
Discussion started by: newbie2010
4 Replies

5. UNIX for Dummies Questions & Answers

UNIX script for reading a file and creating another file

Hi, I am a beginner in scripting...I have to do a script where I have to read a file which has list of job names, line by line and for every line execute a dsjob command to find the log details of the job and extract only the start time of the job, if it is greater than jan 01 2008 and create... (1 Reply)
Discussion started by: Vijay81
1 Replies

6. Shell Programming and Scripting

Reading Delimited file and send mail with attachment

Hi All, My requirement is: 1. To read a file that contains log file location and server name. The format of the file is something like this : server_name1:logfilename1 server_name2:logfilename2 2. Now I wants to grep "error" string from the logfilename and put it into another file for... (3 Replies)
Discussion started by: acheiver
3 Replies

7. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies

8. UNIX for Dummies Questions & Answers

script to reading a file

hi, I have a file containing names, say n number of names, sample file robin smith dallas frey cook all these names are in a file name called names.txt and it is placed in a directory called /data/names all i want is to write a script, which will read from the file and gives the... (3 Replies)
Discussion started by: vasikaran
3 Replies

9. Programming

Reading a file into a C++ script

Hi, I'm trying to read a file in with and assigne the stream to a char * type. I've manged it using the cin.get returning type char, but am having run-time problems returning a char *. For example, char *pStream = "file.txt"; ifstream from(pStream); from.open(pStream); ... (1 Reply)
Discussion started by: Breen
1 Replies
Login or Register to Ask a Question