Solved

bash script to parse standard input from a text file

Posted on 2014-03-27
1
589 Views
1 Endorsement
Last Modified: 2015-03-19
Hi Experts,

I need to write a script (timetable.sh) that parses the contents of a text file and applies it to a 'curl' command using the following command.

cat units.txt | ./timetable.sh

Inside the units.txt file there are 3 lines of text which need to go into bold part of the curl command:

csi3207
csg5116
csi3208

curl -d "p_unit_cd=csg2305&p_ci_year=2014&cmdSubmit=Search" \ http://apps.wcms.ecu.edu.au/semester-timetable/lookup

How can I do this?  I can't seem to find a solution anywhere.

Or even another script that does the same would be extremely useful.

Thanks in advance
1
Comment
Question by:madstylex
1 Comment
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 39958346
#!/bin/bash
while read id
do
   curl -d "p_unit_cd=$id&p_ci_year=2014&cmdSubmit=Search" http://apps.wcms.ecu.edu.au/semester-timetable/lookup
done

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

773 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