The second question should have been asked seoperatly in linux programming.
for the first question:
Quote:
1st to write a program that execute the command ls -a -l dirname where dirname is a parameter given at the program execution in command line or the current dir if the parameter is missing. At the end of execution the program need to write a message
|
you can do this with a shell script. Unfortunatly you will have to learn some basics of shell scripting so look here:
BASH Programming - Introduction HOW-TO
I'd imagin that your script you make will look something like this
Code:
#!/bin/sh
# ls script
# check ror a command line argument
if [ -z "$1" ]; then
echo usage: $0 directory
exit;
fi
#output the directory given to the script
echo dir: $1
#check that the directory exists
if [ ! -r $1 ]; then #if given directory doesn't exist
echo Directory: $1 not found
exit;
fi
# run the ls command
ls -a -l $1
Note this script will not fulfill your criteria but it is an example that will get you started