Board logo

標題: [疑難] A question about Linux [打印本頁]

作者: polomanhk    時間: 2007-11-3 23:19     標題: A question about Linux

I was stuck on question one.
can u help me??
thx



#!/bin/sh
if[-d$1]
then
   echo"The parameter is a directory";
else
   echo"The parameter is not a directory";
fi




--------------------------------------------


The directory structure that you generated in your coursework/tempfiles directory (see section 1) should now be displayed attractively on a web page (in HTML). Since there are many files, you do not want to do this by hand, but instead want to write a script to generate the web page. This section requires you to write a script to automate this and, thus, tests your ability to write shell scripts in bourne shell.

You will find the following manual pages useful: sh, test and cat. (You can of course type man for this, but we also made them available as pdf, which you can access by clicking the command.)

For this section, you will create a single script in five steps. If you do it right, your script will grow with every step, do not attempt to do the whole section in one go. It is a good idea to ask one of the demonstrators to check whether you're on the right track at the completion of each step. The end result of this section is a single script, as well as a web page called ls.html, both of which you have to submit.

The script will take a directory and two file names as parameters, and then produce an HTML listing of the files in the directory. To aid you in this process the task is broken down into several stages. You may refer to the sample output in Note A at the end of this question to get a rough idea what your script is expected to produce when the result is displayed in a web browser.

   1. Start by writing a script that needs three parameters as input. The script should check that there are three parameters and should print an error message if you run it with less or more than three input parameters. In this practical, the first parameter is a name of a directory, the last two are names of two different files. Your script needs to check that the directory and the files exist, and write an error message if a file or directory does not exist. To try out your script, you want to use the following parameters: the directory is coursework/tempfiles, the first file is /ncl/cs/2006-07/csc1006/web/header.html and the second file is /ncl/cs/2006-07/csc1006/web/footer.html. Then see what happens if you introduce typos or omissions in your parameters when you run your script.


Many thanks!!
作者: angelboyz    時間: 2008-3-12 03:58

You still need answer to this question?




歡迎光臨 香港 Xocat Forum 討論區 (http://p.xocat.com/p/) Powered by Discuz! 6.0.0