Solved

bash script to parse standard input from a text file

Posted on 2014-03-27
1
583 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Fine Tune your automatic Updates for Ubuntu / Debian
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

864 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

24 Experts available now in Live!

Get 1:1 Help Now