I'm having problem with taking in arguments and be able to use the content of the argument for something else.
In this case I need to take in user names and check if the person is online using finger or who
For example, my script name is getuser
in shell I type
getuser username1 username2
I want to be able to take username1 and check if he's online then take username2 and check if he's online.
I'm currently just echo ing the argument to understand how to increment.
Note that there may be more then 1 argument.
I know that echo $* will print all the arguments
echo $1 will print username1
echo $2 will print username2
but since I don't know how many arguments there may be, is there a way to increment the $n instead of $1,$2,$3....etc
my code:
#!/usr/dt/bin/dtksh
echo currently logged on:
for((n=1; n<=$#; n+=1))
do
exec 2>errs
echo $n //this just shows the number in n
echo $(n+1) //this won't work
echo $(n = `expr $n+1`) //this won't work either...
done