推介:| 網頁寄存 | 網頁設計 | 開網店 | 電郵申請 | Wordpress Hosting | 外賣平台 | 英語課程推薦 | 風水屋 | 房間風水懷孕 | Timway Testimonial | Wedding Planner | Wedding MC |

發新話題
打印

[疑難] A question about Linux

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!!

TOP

You still need answer to this question?

TOP

發新話題


重要聲明:本討論區是以即時上載留言的方式運作,本網站對所有留言的真實性、完整性及立場等,不負任何法律責任。而一切留言之言論只代表留言者個人意見,並非本網站之立場,用戶不應信賴內容,並應自行判斷內容之真實性。於有關情形下,用戶應尋求專業意見(如涉及醫療、法律或投資等問題)。由於本討論區受到「即時上載留言」運作方式所規限,故不能完全監察所有留言,若讀者發現有留言出現問題,請聯絡我們。本討論區有權刪除任何留言及拒絕任何人士上載留言,同時亦有不刪除留言的權利。切勿撰寫粗言穢語、誹謗、渲染色情暴力或人身攻擊的言論,敬請自律。本網站保留一切法律權利。


Copyright 1997- Xocat. All Right Reserved.