Linux / UNIX Tech Support Forum
This is a discussion on Shell Script To Add Execute permission to the file for the user within the Shell scripting forums, part of the Development/Scripting category; hello... i have one question can you help me...??? please.. Write a script (Named execadd.sh) that will take a single ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
hello... Write a script (Named 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. i have one question can you help me...??? please.. 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. You write it this way: echo "Usage: $0 filename" You must check to see if the file exists; if it doesn't, give an error message. You must check to see if the file is a regular file; if not, give an appropriate message |
| Sponsored Links | ||
|
|
|
||||
|
Try
Code:
#!/bin/bash
FILE=$1
usage(){
echo "Usage: $0 filename"
exit 1
}
[ $# -ne 1 ] && usage
if [ -f $FILE ]
then
chmod +x $FILE
else
echo "Error: $FILE not a regular file."
fi
__________________
Vivek Gite Linux Evangelist |
|
|||
|
really thank you...only this solved....???i don,t understand any thing in linux....!!keep help me always please.beacause myspeciality in the netowrk .
|
|
|||
|
Dear nixcraft
i wish to Continuo the solved would you mind...due to i need it at nearest time ... please .. i'm waitting your response.... best regards bye |
|
|||
|
(write this script ) ???
Write a script (Named 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. You write it this way: echo "Usage: $0 filename" You must check to see if the file exists; if it doesn't, give an error message. You must check to see if the file is a regular file; if not, give an appropriate message What is The rest of this solution ... #!/bin/bash FILE=$1 usage(){ echo "Usage: $0 filename" exit 1 } [ $# -ne 1 ] && usage if [ -f $FILE ] then chmod +x $FILE else echo "Error: $FILE not a regular file." fi . . . |
|
||||
|
This script is the solution. Feel free to modify it as per your requirements.
__________________
Vivek Gite Linux Evangelist |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linux Add User Shell Script | abovenewbi | Shell scripting | 13 | 06-03-2009 02:57 AM |
| Execute UNIX Command / Shell Script Once In The Future | permalac | Shell scripting | 2 | 27-08-2008 08:13 PM |
| Shell Script To Outputs File Permissions of Most Recently Modified File | glen_4455 | Shell scripting | 1 | 25-08-2008 02:39 PM |
| shell script to search specific file from txt file inside zip file and extract it | aasif.shaikh | Shell scripting | 2 | 31-05-2008 06:44 PM |
| If file modified execute a script | karabaja | Shell scripting | 3 | 23-11-2006 02:39 AM |