LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-12-2011, 02:06 PM   #1
natsume
LQ Newbie
 
Registered: Apr 2007
Location: Malaysia
Distribution: Debian & Ubuntu & Opensolaris
Posts: 4

Rep: Reputation: 0
I dont know what we call this.


Hi All,

need your help here.

i want create a script that will read

1. user.txt ( probably will have 20 - 50 user list)
2. alert.txt (only have 1 line)

lynx -dump "http://localhost/cgi-bin/alert?user=$user&text=$alert"

So far i only managed to use looping

for user in `cat user.txt `; do lynx -dump "http://localhost/cgi-bin/alert?user=$user&text=i have to set this manually";done

Is there any workaround ?


Thanks.

Last edited by natsume; 07-12-2011 at 02:08 PM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 07-12-2011, 03:00 PM   #2
CapnStank
Member
 
Registered: Oct 2009
Distribution: Fedora, HPUX
Posts: 31

Rep: Reputation: 2
Code:
alert = cat alert.txt
users = `cat users.txt`

for user in $users ; do
  lynx -dump "http://localhost/cgi-bin/alert?user=$user&text=$alert"
done
This is what you have essentially correct? What is wrong with it or are you just looking for process improvement?
 
Old 07-12-2011, 07:29 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
No spaces around the 'equals' sign in assignments in bash. But you don't need all that backtick stuff anyway
Code:
read alert < alert.txt
while read user; do 
    lynx -dump "http://localhost/cgi-bin/alert?user=$user&text=$alert"
done < users.txt
--- rod.
 
2 members found this post helpful.
Old 07-12-2011, 11:45 PM   #4
natsume
LQ Newbie
 
Registered: Apr 2007
Location: Malaysia
Distribution: Debian & Ubuntu & Opensolaris
Posts: 4

Original Poster
Rep: Reputation: 0
problem solved :

#!/bin/sh
calert=`cat alert.txt `
cuser=`cat user.txt `
for ccuser in $cuser; lynx -dump "http://localhost/cgi-bin/alert?user=$ccuser&text=$calert" ; done
 
Old 07-13-2011, 06:45 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Note that it's best to use $(command) instead of backticks, since it can't be confused with single quotes and nests easily.
 
Old 07-13-2011, 06:45 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Note that it's best to use $(command) instead of backticks, since it can't be confused with single quotes and nests easily.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Noob PPPoE ,WLAN problem (dont know what to call it) khaleel5000 Linux - Networking 3 05-02-2011 12:58 AM
i dont know what to call this fakie_flip Linux From Scratch 4 09-15-2005 09:56 PM
SSH (dont know really what to call this...) Totoro Linux - Newbie 2 03-19-2004 09:42 AM
new to linux dont what distro to use dont no much command xman2007 Linux - Newbie 3 01-02-2004 05:32 PM
Things dont work when you dont understand withoutaclue Linux - Newbie 3 03-12-2003 09:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration