Computing.Net > Forums > Unix > Unix SHELL SCRIPTS

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Unix SHELL SCRIPTS

Reply to Message Icon

Name: V
Date: April 21, 2003 at 18:43:57 Pacific
OS: Wnin2000
CPU/Ram: PII/64MB
Comment:

I'm a student, and I have a hard time completing this term assignment, if anyone could help me I would appreciate it very much. I did my best to do it but the output is not good. I use Win2000 Command prompt to connect via Telnet to Unix server at my college.

For this assignment, I need to do the following:

_____________________________________________
1. Create a SHELL SCRIPT within your HOME DIRECTORY called ABScript that will:

- Display the script name
- Display all users currently logged onto the system
- Display how many users are currently on the system (ie. add up the logged in users)

2. Create SHELL SCRIPT within your HOME DIRECTORY called CDScript that will:

- Display the script name
- Display the active processes
- Start the Bourne Shell

3. Create SHELL SCRIPT within your HOME DIRECTORY called EFScript that will:

- Display the script name
- Display the active processes
- Display a message that you are now calling up the KORN Shell
- Call up the KORN Shell
- Display the active processes
- Display that you are going to terminate the KORN Shell
- Terminate the KORN Shell
- Display the active processes

4. Create a SHELL SCRIPT within your HOME DIRECTORY called BIGScript that will:

- Display the script name
- Execute ABScript, CDScript, EFScript
- Display "END OF RUN"

_______________________________________________________________________________________________

This is how I did it (but the output doesn't satisfy):


1st Script: echo "ABScript"
who -H
who -q

2nd: echo "CDScript"
ps
sh

3rd: echo "EFScript"
ps
echo "Now calling up the Korn Shell..."
ksh
ps
echo "Now terminating the Korn Shell..."
kill

4th: echo "BIGScript"
ABScript
CDScript
EFScript
echo "END OF RUN"




Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: April 21, 2003 at 19:36:49 Pacific
Reply:

OK. Honesty gets you big points here.

-----8-----cut here----8-----
#!/bin/sh
echo $0
cnt=`who | wc -l | awk '{ print $1 }'`
who -H
echo "$cnt users currently logged in"
-----8-----cut here----8-----
#!/bin/sh
echo $0
ps -ef
( pwd ; ls -1 ; date )
-----8-----cut here----8-----
Hope this helps.


0

Response Number 2
Name: David Perry
Date: April 22, 2003 at 04:25:07 Pacific
Reply:

cat EFscript
#!/bin/sh
KSH=`which ksh`
echo "#!$KSH" > korn.sh
cat > korn.sh
echo "Starting KORN shell spawned process"
set | grep -i shell=
ps -ef
echo "Ending KORN shell spawned process"
EOT
chmod ugo+rx korn.sh
. ./korn.sh
ps -ef


0

Response Number 3
Name: peter
Date: May 8, 2003 at 06:43:28 Pacific
Reply:

I don't want to put you down or anything, but I am not sure I beleive you that you "tried" Did you evel look on google ?

Anyway, here is the code for the first one anyways. I hope it will get you started.

________________________________________
#!/bin/sh
who
echo " the num of us .... is: `who | wc -l`"
echo $0

_________________________________________

line 1 starts the shell
line 2 displays all users logged in
line 3 the "| wc -l" (L) takes the output from
wc -l (which counts the "words") and
makes it the input for who.
therefore you get the number of users
line 4 prints the first thing you typed on
the command line (ie the name of the
script)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


prevent a file from being... Encrypted password 64 cha...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Unix SHELL SCRIPTS

Unix Shell Script www.computing.net/answers/unix/unix-shell-script/3580.html

Unix shell script runing SQL files www.computing.net/answers/unix/unix-shell-script-runing-sql-files/5286.html

Unix shell script problem... www.computing.net/answers/unix/unix-shell-script-problem/6217.html