Doesn't work, the $ makes in front of finger makes it think that finger is a variable.
Expanding a bit on what MadeInGermany already said... the code rdrtx1 suggested:
does not have a dollar sign in front of finger; it has a dollar sign in front of an opening parenthesis. What rdrtx1 suggested was to execute the pipeline finger $i | wc -l and store the output written to its standard output in the variable named tst.
Your code:
(making the wild assumption that you are using a shell that has array variables) attempts to make tst an array of values that arise from splitting the string finger current_value_of_variable_i | wc -l but gets a syntax error because a pipeline has higher precedence than assigning an array to a variable. And, if you get past that syntax error (and ignore the probable bug in the command substitution:
which will be treated exactly the same as the common substitution:
when I'm not sure whether you wanted to alternate between <space> and <newline> or just want to replace all occurrences of <semicolon> with <space> or to replace all occurrences of <semicolon> with <newline>), we then get to the syntax errors in your if statement:
which (assuming that you are using a shell based on Bourne shell syntax) requires a space between [ and $tst and between 0 and ] and for a numeric comparison should use -ne instead of !=. Then we also have the problem that we do not know what system you're using and what output its version of finger produces when a user is looked in and when a user is not logged in. On OS X (using a BSD based finger utility) finger produces five lines of output for a user that is not logged in and 5 + n lines of output for a user that is currently logged in n times.
So, if we remove all of your syntax errors, it appears that what you are trying to do is remove all of the <semicolon> characters from the string stored in the variable gidlistTemp and store the result of that conversion in the variable named gidlist.
But, since you have never told us what you are trying to do, what operating system you're using, what shell you're using, nor the exact "bunch of errors" your script is producing; we are left to make wild guesses at how to correct your script. If you would be willing to share all of this information with us, we might be able to help you correct your script to do what you want to do.
I am looking t run root level command on multiple servers, but all servers have only "su - " permission available in sudoers.
please help me if any way that I can run command using help of "su -"
My script
for hosts in `cat hosts.txt`;
do
echo "###########################Server Name-... (5 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hello All,
I am running source command on my project configuration file app.cfg which has conditional statements with make file systax E.g ifeq ($(APP_CMP_DIR),trunk).
When I source this file it throws error: syntax error near unexpected token... (1 Reply)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi,
After run ps , uptime , w command I get reply "killed" as normal dba and staff group user.
As root every command works fine.
I cheched all the user settings , right with other servers and I could not find any error and other settings.
The oslevel is 5300-10-01-0921.
Any idea to... (12 Replies)
A strange observation -
$ ksh date
ksh: date: cannot execute
$ ksh "date"
ksh: date: cannot execute
$ ksh "date "
Thu Sep 18 09:22:12 CDT 2008
why the date command doesn't run without a space ??
Please help (3 Replies)
heya,
can someone help me with following problem.
i am not sure how far you know the catalina.sh script from tomcat. when i start my tomcat with "catalina.sh run" then the startup-process-output will be printed out on the console, but the tomcat process is started in current shell/session, so... (1 Reply)
Hai,
In order to find out a user we can use finger "username" .
The output of finger command has various details in the following manner :
Login name: xyz In real life: xyz
Directory: /home/xys Shell: /bin/ksh
No unread mail
No plan
What is the plan... (1 Reply)
Hello All.
I'm get the following messages posted to the /var/adm/syslog file ever second and not sure on how to stop the process.
May 14 15:50:52 a3360 bootpgw: version 2.3.5
May 14 15:50:52 a3360 inetd: /etc/bootpgw exit 0x1
As said about this gets logged every second only thing that... (4 Replies)