?
Solved

bash script to parse standard input from a text file

Posted on 2014-03-27
1
Medium Priority
?
623 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 …
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

771 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