all of our *nix systems are using local user accounts still, so i have come up with a management script to handle useradds / deletions / password resets etc. It is functional, but now i am trying to go through and reduce the number of ssh calls and clean up my messy coding. As it sits right now, this little section could potentially have 8 different ssh connections for just this little function..
I have searched all over to see if there is a way for me to gather more of the information that i am needed to run this code more effeciently (ie less ssh calls) but am having a hard time finding a way to set local variables from remote systems without doing a
VARIABLE=`ssh some_command`
for each one i need to gather
This is just one function in the script so there are things that are ommited such as the gathering of the arrays etc, but if anyone could give me some pointers or ideas for this section, i am sure i could adapt them to the other functions of my script
You can reduce the number of ssh connections by doing more things with one ssh call. You can run entire scripts, not just single commands: ---------- Post updated at 10:16 AM ---------- Previous update was at 10:11 AM ----------
Also, you have some useless use of cat and useless use of backticks in there.
You don't need 'cat' there. You don't even need to check the output string, just grep's return value, so you don't need backticks either.
i appreciate the pointers.. i may just have my scripts built to do things a non-optimal way, but because of the way they are currently designed, your examples dont appear to work for my situation.
My script(s) all run from a single server (doesnt matter which since it is a shared nas mount) and goes out and executes the commands on to the remote systems.. so for your example of
i am not able get the echo'd information back to the source server that is running it since it is running the echo on the remote system side. I use that info for the synopsis once it is done looping thru all servers..
For the other tip you gave me to reduce my ssh calls, again the issue is that i can echo the arguments, but i can't use that information since the source server knows nothing of the arguments on the remote system.. So my echo will return the uname output, but the source can't use that to determine what is needed to run the commands as root..
although everything you had helped with is functionally correct, it doesnt work for my script layout.. This is most likely an issue of my script(s) not being laid out the best way. Should i instead be pushing the scripts execution off to the remote servers instead of trying to run it all from a single source?
again, i do truly appreciate the help.. i seem to be able to come up with functional scripts, but i am still learning how to make clean, effecient, functional scripts!
ok.. that makes sense.. however the issue that i now run into with that, is i get all of the other shell output in addition to the "Deleting user succeded" output
that makes sense, because this is all the info in stdout, but the only thing i need is the echo that says the status
besides coming back around and removing all the extraneous content in the file with something like sed/awk, is there anyway to overcome this?
That's very odd -- a shell run noninteractively really shouldn't be doing that! Try exec /bin/sh instead of just /bin/sh. If that doesn't work try an alternative shell, /bin/ksh or /bin/bash or what have you, instead of basic sh...
Hello,
I need some help from unix guru's here..I am looking for some advanced level script to cleanup the directories and files from specific directories under a file system..
The folders are created under /opt/modules
And under modules, there are multiple subfolders with the application... (6 Replies)
I have a server running redhat 5.5 and it has one SAN device presented to it as LUN9. How can I clean up the remaining entries. I cannot afford to interupt the service. Please assist.
# multipath -l
mpath0 (36000097000019260298953666633436) dm-11 EMC,SYMMETRIX
\_ round-robin 0
\_ 2:0:0:9 ... (2 Replies)
I needed some help with a script to fetch and delete all records prior to 3 days from now connecting to sybase from sunos. I wrote the following script but not working..can someone please guide me with my code.
Thanks
#!/bin/ksh
##GET PREVIOUS DAY DATE
dt=`date | awk... (3 Replies)
Hi,
I am trying to clean up data between parenthesis () in a file.
See example below....
Input File :
(New York) Chicago (London)
New York (Chicago) London
New York Chicago (London)
(New York) (Chicago) (London)
New York (Chicago)
... (3 Replies)
Hi All,
I have this script for linux on cleaning up orphaned folder. But I need to use this on solaris 8/9/10
for user in $(ls | grep -v lost+found) ; do
id $user >/dev/null 2>&1
if ]
then
ls -ld $user
grep $user /etc/passwd
fi
done
Can someone please convert this script? ... (1 Reply)
Hi!
I would like to write a script which remove some files, all beginning with the same prefix :
prefix.1
doc/prefix.2
../prefix.3
etc.
So, I would create a file and chmod it executable. But I dont know how to pass a variable to a script. I would like to write something like
... (2 Replies)
I am trying to add a unique string to a variable to prevent some name space collisions.
DATAFILE=/u001/app/unica/affinium644/campaign/partitions/limited/tmp/ebf9aaah.t~#
DATETIME=`date +%Y%m%d_%H%M%S`
echo $DATAFILE > tmpnme.txt
sed 's_/_ _g' tmpnme.txt > tmpnme2.txt
DATA=$(cat tmpnme2.txt)... (2 Replies)
Is there any facility to filter/identify the data calls and voice calls coming throug modem?
OR
Can we get the data or voice calls information through a script(preferably C Kermit)? (0 Replies)
Hello
I have many old IDs on my AIX and would like to know the
simplest way of knowing the last time an ID was used.
I am familiar with the "last" command.
Thanks for any info :) (1 Reply)