User user1 may run the following commands on server2:
(ALL) ALL, !/bin/su
ksh: user66: not found
ksh: dbuser: not found
ksh: tomcat: not found
ksh: splunk: not found
ksh: stash: not found
ksh: jira: not found
ksh: ^J: not found [No such file or directory]
ksh: docadmin /etc/passwd: not found [No such file or directory]
I run this command across a set of 500+ servers.
I also tried using egrep but it still did not work.
Note: Strangely grep -iE "user66|dbuser|tomcat|splunk|stash|jira|user2|docadmin" /etc/passwd works fine with ksh shell when i manually fire it from the remote server2
I m looking for a solution by which I could enforce to either use bash shell on remote servers or have a grep / egrep / fgrep / ggrep or by specifying complete path to a particular grep command that works across different flavors or unix Linux servers.
Last edited by mohtashims; 01-18-2019 at 11:42 AM..
Note: Strangely grep -iE "user66|dbuser|tomcat|splunk|stash|jira|user2|docadmin" /etc/passwd works fine with ksh shell when i manually fire it from the remote server2
Sigh, here we go again: have you actually read what i wrote in response to your problem yesterday? Now you cram (again) fifteen commands into one commandline and wonder why you get confused - honestly, i would get confused too and i think i know a bit or two about shell programming.
Actually, strangely, you explicitly fire up a bash, which is not a ksh and that two different shells behave differently sometimes is not "strange", it is no wonder.
Second, you seem to think that quotations can be nested:
Inside a single-quoted string a double-quote character is just a normal character (besides: and vice versa). That is:
are just two quoted strings, a double-quoted one and a single-quoted one. The single-quotes in the first and the double-quotes in the second are just one more character.
Third, you have now read probably a hundred times that YOU SHOULD NOT USE BACKTICKS! How often does someone have to point that out to you until you realize that some of us actually know what we are talking about? It is utterly frustrating to solve the same problem over and over again for you because nothing anybody here is telling you seems to have any lasting effect. By the way: also the backticks are just simple characters with no meaning at all inside a single-quoted string. Try this on the commandline:
and you will see a simple string `date` in the output, not the date itself.
Alas, i suppose you will ignore what i write again, so i spare you (and me) advice on how to do better what you want to do. You won't heed my advice anyway.
Hi ,
I have written a small script :
set -x
#!/bin/ksh
for i in `cat /tmp/list` ( list contains remove servers )
do
ssh -t $i << EOF
uname -a
cd ~user
echo "Enter the dir >"
read dir
path=`ll -ld /home/user/"$dir"`
if ; then
echo "Dir exists "
read
rm $path
else
echo "no such... (9 Replies)
Hi
Wishing to all.
I am very new joined in an organization as a unix system administrator.
I need a help in preparing a script for a report.
i have a file contains all of the linux/ubuntu servers line by line around 140 servers.
vi servers.txt
nh01
nh02
nh03
bh01
bh04
-
-
:wq (3 Replies)
Hi all,
I am baffled on this. Solaris Irix system.:confused:
I have 4 servers all connected to one another, :b: I need to write a script line that would login on to server 1-3 ($HOST) start a script in the back ground and log off while the back ground script runs over a length of time.:eek:
... (10 Replies)
Suppose i have 3 different servers say x,y and z.
Im running some process say ABC and 40 instances for the same is being created.
In load sharing suppose on
server x, 20 instances are running
server y, 10 instances are running
server z, 10 instances are running.
While checking the... (1 Reply)
I'm trying to connect a few servers in different remote locations to my HMC. I added static IPs to the Service Processor through ASM, and did all the necessary network configurations, then connected those servers to our switch. Now my questions are:
- in our site, do I need to connect these... (4 Replies)
Experts,
Im trying to remote into a server, run a script that resides on that server and capture the information displayed & store in a local file.
I struggled with this yesterday & finally that script is working now.
Now, here is a scope creep and the script that I wrote for 1 remote... (2 Replies)
Hi guys - newbie question:
Is there a way for me to grep running processes from a windows machine? If its possible I could then try to script it.
Currently I can see Windows file shares on my Linux server. (4 Replies)
Hey Unix Gurus,
I'm having trouble in copying a file on 5 different servers, first how can you do it locally (i.e without the need to ssh to the server you want to copy the file) and if you need to ssh how do u run a command within that server. Please see my code below(it doesn't work somehow).... (10 Replies)
Please advise,
The previous thread asked about the automated transfer of files between two servers. The question is - is there any way of encrypting the password within the script or is it a matter of setting the permissions settings on the script so that it can only be executed and possibly... (1 Reply)