المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : لينكس ارجو المساعدة بالسرعة القصوى



seaman77
16-03-2009, 12:07 PM
ارجو المساعدة بحل مشكلة السكريبت التالي
Write a script (execadd.sh) that will take a single filename as an argument and adds execute permission to the file for the user, but only if the file is a regular file.
Your script must check to see that there is exactly one argument. If there are no arguments or more than one arguments, your script must produce a "usage" message that tells how to use the script.
Here is the result of running the script several times, with extra
blank lines to make things more readable.
linux199@linux:~> touch file1
linux199@linux:~> mkdir dir1
linux199@linux:~> ./addexec.sh
Usage: ./addexec.sh filename
linux199@linux:~> ./addexec.sh file1 file2
Usage: ./addexec.sh filename
linux199@linux:~> ./addexec.sh dir1
dir1 is not a regular file.
linux199@linux:~> ./addexec.sh nosuchfile
nosuchfile does not exist.
linux199@linux:~> ls -l file1
-rw-r--r-- 1 linux199 users 0 2006-11-21 17:38 file1
linux199@linux:~> ./addexec.sh file1
linux199@linux:~> ls -l file1
-rwxr--r-- 1 linux199 users 0 2006-11-21 17:38 file1

هذه محاولتي بحل هذا السكريبت ولكنه لايعمل ارجو منكم المساعدة
!/bin/sh
If [$# -ne 1] # check if number of argument is not equal to 1
Then
Echo “Usage: $0 filename” # giving a Usage Message
Elif [$# == 1] # check if number of argument is equal to 1
Then
If $1 –f # checking if file is existed
Then
chmod 775 $1
# Adding execute permission to make file readable and executable by others, but only changeable by the issuing user.
Else
Echo “file isn’t a regular file”
Fi
Else
Echo “error: file does not exist” # giving a Error Message
Exit 0
Fi

seaman77
18-03-2009, 10:59 AM
ارجو المساعدة باصلاح السكريبت فانا عجزت عن ذلك ومحتار

Argonaut
19-03-2009, 12:54 AM
السلام عليكم
كان ودي اساعدك لكني ما اعرف