Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help4407


This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting (CITS4407).

Assignment 2 and Clarifications.
 
Options:
RSS cloud
Jump to:

Assignment 2, Q2

13 of 390 articles shown, currently no other people reading this forum.
photo
From: Mingbo Z.
Date: Thu 14th May, 3:10pm
Actions: 
        Login-to-reply
Hi Chris,

For the task2, the data is always from a text file, right? Thank you!

Assignment 2, Q2

photo
From: Christopher M.
Date: Thu 14th May, 3:48pm
Actions: 
        Login-to-reply
"Mingbo Zhang"                               wrote:

> Hi Chris,
> 
> For the task2, the data is always from a text file, right? Thank you!

Yes, in the very same format as the sample (real) file provided.

Assignment 2, Q2

photo
From: Thanh T.
Date: Fri 15th May, 2:25am
Actions: 
        Login-to-reply
When I used loop to print each line the file. It printed out 
"10.4.0.14
-
-
[03/May/2020:03:09:27 +0800]
"GET
/run/help2200?p=np
HTTP/1.1"
200
42477"

It is not on the same line. Does this question require us to do some data cleaning 
before draw charts?

Assignment 2, Q2

photo
From: Christopher M.
Date: Fri 15th May, 3:55am
Actions: 
        Login-to-reply
"Thanh Tang"                               wrote:

> When I used loop to print each line the file. It printed out 
> "10.4.0.14
> -
> -
> [03/May/2020:03:09:27 +0800]
> "GET
> /run/help2200?p=np
> HTTP/1.1"
> 200
> 42477"
> 
> It is not on the same line. Does this question require us to do some data cleaning 
> before draw charts?

I cannot tell what you mean by "I used a loop...", as there are many possible ways.
But my guess is that you have something like:

for i in `cat filename`
do
     echo $i
done
This will not work as you probably hope, because placing a command in backquotes requests that all of its output is appended onto one long line, with each of its original lines now separated by spaces. Easily verified with a simple file of just 3 lines. If this is what you're doing, change from that "for i in ..." loop to one using ""while read line ; do ...." and the input lines will be preserved each time around the loop. Then *you* can break each line into its fields.

Assignment 2, Q2

photo
From: Thanh T.
Date: Fri 15th May, 12:32pm
Actions: 
        Login-to-reply
Thanks Christ. 

Assignment 2, Q2

photo
From: Mingbo Z.  O.P.
Date: Fri 15th May, 4:31pm
Actions: 
        Login-to-reply
Hi Chris,

For task 2, do we need to do the data clean? Or we just need to write out the script 
to draw the graph no matter whether the data is noisy. Thank you! 

Assignment 2, Q2

photo
From: Mingbo Z.  O.P.
Date: Fri 15th May, 5:04pm
Actions: 
        Login-to-reply
One more question, the foramt of month in logfile is short one or full one? Thank 
you!

Assignment 2, Q2

photo
From: Christopher M.
Date: Fri 15th May, 5:17pm
Actions: 
        Login-to-reply
"Mingbo Zhang"                               wrote:

> Hi Chris,
> 
> For task 2, do we need to do the data clean? Or we just need to write out the script 
> to draw the graph no matter whether the data is noisy. Thank you!

The logfile provided is a real one, and you can presume that any others will also be real.
No need to clean the data, as there (shouldn't) be any noisy data in it.

Assignment 2, Q2

photo
From: Christopher M.
Date: Fri 15th May, 5:19pm
Actions: 
        Login-to-reply
"Mingbo Zhang"                               wrote:

> One more question, the foramt of month in logfile is short one or full one? Thank 
> you!

Sorry, I don't understand the question.

The first line in the same has (only) this date:  03/May/2020
What do you mean by short or full ??

Assignment 2, Q2

photo
From: Mingbo Z.  O.P.
Date: Fri 15th May, 5:54pm
Actions: 
        Login-to-reply
I mean like if we get data from April. the month format in logfile would be Apr or April? 

Assignment 2, Q2

photo
From: Christopher M.
Date: Fri 15th May, 6:04pm
Actions: 
        Login-to-reply
"Mingbo Zhang"                               wrote:

> I mean like if we get data from April. the month format in logfile would be Apr or April? 

All months just 3 characters long. Thanks.

Assignment 2, Q2

photo
From: Jordan M.
Date: Wed 20th May, 3:33pm
Actions: 
        Login-to-reply
Hi Chris,

Do you have a preference on whether our shellscript takes the text file url as an argument 
when run from the command line or would you prefer its url pasted in and downloaded within 
the script? 

For the purpose  as if you were to use the shellscript in the future for an updated version 
of the text file.

Thanks,
Jordan

Assignment 2, Q2

photo
From: Christopher M.
Date: Thu 21st May, 7:52am
Actions: 
        Login-to-reply
"Jordan Makins"                               wrote:

> Do you have a preference on whether our shellscript takes the text file url as an argument 
> when run from the command line or would you prefer its url pasted in and downloaded within 
> the script? 

Hi Jordan,

It's always preferred to have a more general script, one that can process different inputs (without 
having to change the script itself - which is actually much easier with a scripting approach, than a 
compiled approach).  So, yes, use of a command-line argument is preferred.

But it's simple to support both by checking if an argument was provided:

if [ $# == "0" ]
then
    inputfile="default-input-file"
else
    inputfile="$1"
fi
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  8:27am May 24 2020