Click to See Complete Forum and Search --> : shell scripting...please help!!!


j0j081
05-05-2003, 04:40 AM
I've been having a lot of trouble with the following script file. Any help would be greatly appreciated. BTW. I'm not asking you guys/gals to solve it for me completely (although that would be nice), I'm mainly looking for hints/directions on how to solve it.

1. The command dirinfo with no parameters should respond with your name and the date you wrote the script file.
2. The command dirinfo dirs will display the number of directories in the current directory.
3. The command dirinfo files will display the number of files in the current directory.
6. Output an error message if dirinfo is run and none of the above conditions are specified.

Thanks!

chrism01
05-05-2003, 07:40 AM
1. use whoami, and maybe ls -l on filname, then grep out the date.
2. Try ls -1FC|grep '/'|wc -l
3. Try ls -1|wc -l, the subtract the numbers, or loop through the dir one file at a time, using the 'file' cmd.
6. check the param values stored in $1, $2 ... etc

HTH
PS written off the top of my head as I'm doing this from a win2k box. Should be fairly accurate tho'
Have fun.

bwkaz
05-05-2003, 09:35 AM
For 1, do you need your (i.e. the author's) name, or do you need the user's name? whoami will give you the user's name.

If you want your name, look into echoing a fixed string.

j0j081
05-05-2003, 05:40 PM
For 1 I need my user name. In this case it is going to be UX04.

bwkaz
05-05-2003, 09:44 PM
Should it print UX04 no matter who runs it? (your teacher won't log on as you...)

j0j081
05-06-2003, 01:46 PM
sorry! i asked today and we only need the author's name. it doesn't need to display the current user.

elote_caliente
05-06-2003, 06:07 PM
Attached is a script that does what you need it to do.
I used the bash shell but you can use it for the korn shell as well.
simply change #!/usr/bin/bash to #!/usr/bin/ksh. if you have any questions feel free to ask!


-let me know if it was helpful:)

elote_caliente
05-06-2003, 06:24 PM
Actually...
I think it would be better to remove everything that is placed after "echo by:" and replace it with your name. You should also do the same for the date.
:o