Solved

bash script to parse standard input from a text file

Posted on 2014-03-27
1
579 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
Comment Utility
#!/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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

10 Experts available now in Live!

Get 1:1 Help Now