printing in shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting printing in shell
# 1  
Old 05-02-2002
Question printing in shell

i need to get this done for college and am having troyble getting the comma removed at the last email address and also if there is no email address i get a space instead of nothing, the question is below so if anyone has an idea how to do it could they help me also u cannot use perl

Background: In a web page, an email link like:

Mail me!
is written as the HTML code:

<a href="mailto:user@domain"> Mail me! </a>
or, for multiple addresses on the same button:

<a href="mailto:user@domain,user@domain"> Mail me! </a>
Functionality:
The script will find all the lines in the input stream on which there is a "mailto" tag.
You can assume that the mailto tag if it exists is the first HTML tag on the line.
You can assume there is at most only 1 mailto tag per line.
You can assume that all the mailto:address expressions are surrounded by double quotes (i.e. just as in the examples above).

It will parse those lines to remove only the actual addresses (the "user@domain" parts) and print them to standard output.
It will collate them in std output in such a form that they could be pasted immediately into an email address line, i.e. they should be separated by commas.
There will be no leading or trailing commas.
It will output nothing at all if there are no mailto tags in the input stream.
When I say nothing, I mean nothing. No blank spaces. No blank lines. Nothing.
Usage of this program is like: cat file.html | filtermailto
Output should look like:

user@domain,user@domain,user@domain,user@domain,user@domain
<../../Icons/new.gif> I expect these to be printed out in the order they are found - first found in the input stream, first printed.

<../../Icons/new.gif> Some people are printing a trailing comma, and then trying to remove it with a backspace: printf '\b'
This works at the command-line, but strangely enough doesn't seem to work in the CGI environment. So better not to print the comma in the first place.

Things you might need: "cut" and "printf".

Note this program could be used in a useful way - a user keeping their contacts list in HTML, with mailto buttons for each person, and occasionally building up a list mailing. Or it could be used in a harmful way, by evil spammers grabbing addresses off other people's web pages.

Tip: Test your program on a file containing the following line:

<a href="mailto:addresses"><img src="../Icons/mailto.gif"></a>
It should extract the "addresses" bit only.
# 2  
Old 05-02-2002
Please take the time to read the rules.

And when you do, take a look at rule number 6.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing line in shell script

Need assistance in getting a shell program . I have csv file and each line has comma separated number. I wanted to take of the comas and print each number in each line . below example. Appreicate your help Row with number ... (14 Replies)
Discussion started by: ajayram_arya
14 Replies

2. Shell Programming and Scripting

Shell : eliminating zero values and printing

I have a log file containing the below data and should have the output file as below. and the output file should not contain any 0 values. Eg. It should not contain 0000000:0000000 in it. input.txt Media200.5.5.1 00010003:065D1202 Media100.5.5.2 7,588,666,067,931,543... (6 Replies)
Discussion started by: scriptscript
6 Replies

3. Shell Programming and Scripting

Help with printing new line in shell script

I'm having a script which outputs four different attributes A, B, C, D for a list of users. I want to insert expression such that once the output is generated for first user, output for next user should be printed in new line. Please help. (4 Replies)
Discussion started by: surdileep
4 Replies

4. Shell Programming and Scripting

Need help with Korn Shell script for substring printing

Hi all, I am new to scripting. I have a file with colon separated values called mylist.txt cat mylist.txt 192.123.76.89:lmprod89 162.122.20.28:lmtstserver28 10.80.32.139:hewprod139 . . using our internal os utility (called mvsping) we need to check all these servers if they are... (6 Replies)
Discussion started by: kraljic
6 Replies

5. Shell Programming and Scripting

Printing from Shell Script

My print alias that works fine from the command line does not function from withn a shell script. Instead of actually performing the printing, it instead writes out the name of the file I'm trying to print. Does anyone know why? Much Thanks. (3 Replies)
Discussion started by: ttilsch
3 Replies

6. Shell Programming and Scripting

shell script, why isn't if printing message?

Why isn't printing message? 1 #!/bin/sh 2 3 something(){ 4 echo "Inside something" 5 echo $1 $2 6 } 7 val=$(something "Hello " "world") But it prints. 1 #!/bin/sh 2 3 something(){ 4 echo "Inside something" 5 echo $1 $2 6 } 7... (4 Replies)
Discussion started by: cola
4 Replies

7. Shell Programming and Scripting

printf in bash shell not printing negative values

hi i am using printf in a script and it is not printing negative values..i have to use printf to get rid of the newline..here is my code: fin=`echo $a - $b | bc` printf "${fin}," >> test these statements are in a loop. here is what i get when i try to subtract 4 from 8: ./scr1: line... (2 Replies)
Discussion started by: npatwardhan
2 Replies

8. Shell Programming and Scripting

help needed in a shell script for printing files

Hi All, I am writing a shell script to print all the files in a particular folder. This script is on solaris server . I am using the lp command to send the requests . lp -d printername filename . The output I get is the request id. Is there any way I can use the request Id to determine if... (1 Reply)
Discussion started by: shahshilpa
1 Replies

9. Shell Programming and Scripting

Problem printing the property of xml file via shell script

Hi, I have a config.xml which cointains the tags like <CONFIG> <PROPERTY name="port" value="1111"/> <PROPERTY name="dbname" value="ABCDE"/> <PROPERTY name="connectstring" value="xyz/pwd"/> </CONFIG> This file is in some directory at UNix box. I need to write a... (4 Replies)
Discussion started by: neeto
4 Replies

10. Shell Programming and Scripting

printing last argument in shell script

All, I am having a shell script and i will pass different argument diferent time . Please tell me how can i find the last argument that i passsed each time when i exec the script. Thanks, Arun. (5 Replies)
Discussion started by: arunkumar_mca
5 Replies
Login or Register to Ask a Question