Hi All,
I have written a (bash) function which generates multiple files say file1 file2 file3
now I want to reduce the generation of these three files i.e. store the output of three files in variables, and generate the same results, in-order to avoid multiple creation of files
how is that possible can any one suggest a code please...
functionA ()
{ poihostname=$1
ssh -n $poihostname /usr/ucb/ps -awwx | egrep "java|sys1" | awk '{print $1,$5}' > file1
cat file1 | awk -F/ '{print $1,$3}' > file2
while read userpid username
do
ssh -n $username@$poihostname pwdx $userpid | awk '{print $2}'>> file3
done < file2
while read path
do
egrep "^${path}$" file3
if [ $? -ne 0 ]
then
echo "DEV path $path is missing " >> finalresult
fi
done < masterfile }
Without seeing/knowing every single detail of your files 1 - 3, it seems to me that you could do without any of them by creatively piping the results.
If you post some more details, we might be able to put together a reasonable solution.
Hi, I was working on this ...for long time & stuck at some point
Now I m passing 3 variables poihostname userpid and username
poihostname =dellsys.com
while read userpid username
do
ssh -n $username@$poihostname pwdx $userpid | awk '{print $2}'>> currpids
done < ss
ss is filename and output is generated in a file called currpids.
more currpids
dell/server/serevr
dell/server/apache
dell/server/weblogic
now my requirement is I want to store the output in a variable instead of storing output in a file(currpids)........I have created a code but I m getting output for only third value(dell 457) & im not getting the output for 1st & 2nd values from file ss , let me know If your require any more info
more ss
dell 123
dell 456
dell 457
I m passing 3 parameters in file ss, but not getting accurate results
my new code look like this
while read userpid username
do
currpids_71=`ssh -n $username@$poihostname pwdx $userpid | awk '{print $2}'`
done < ss
$ for s in ${currpids_71}; do echo "do something with $s"; done
do something with dell/server/serevr
do something with dell/server/apache
do something with dell/server/weblogic