I have the following block from a script (it's not the entire script, but I'm confident it's all that is pertinent)
First, format your code so that it is more easily readable:
Then quote variable references:
You have 6 calls to grep and two to awk for every iteration of the loop. It would probably be more efficient to process the input before entering the loop, but you haven't supplied the contents of $SESSIONS, so it may not be.
Quote:
which returns:
However, when I uncomment the shh command and comment out the echo command, it only goes through the first asset ID in the loop, and then exits out of the script.
I've tried wrapping the SSH in every combination of single quotes and double quotes I can think of, and it always does just the first value from the loop and then exits. I'm stumped.
It shouldn't in this case (because there's a command), but ssh normally reads from the standard input, so it would read the entire output of "echo".
If the problem persists after fixing the quoting, try adding the -n option to ssh.
Quote:
Note: it says psh, but that's because this is being done from an xcat machine. It should work exactly the same as ssh, and in an attempt to debug, I tried using ssh, and it was the same problem.
Note2: In the final version, the ssh command will be in a variable,
That could make quoting even more problematic, unless it is only the command itself in the variable and not the arguments.
Quote:
and I'll be awking out a column of what it retuns (SESSIONID=$(ssh blade grep yadda yadda|awk '{print $9}'). I don't know if that matters.
good day. i jsut wanted to know what is the best script or the best way changing a lot of Ip's in all servers. Do you have any idea? im using awk to change IP,what if, you have lots of servers. You need to change it one by one? It will take time to change it manually. (2 Replies)
I want to connect to a remote server which I have a mySQL DB on, and do a mysqldump so I have a backup. I will likely schedule this with CRON to run every night.
However, to make any changes to the mySQL server I have to SSH onto it, binding my local mySQL port to the remote one.
Is this... (1 Reply)
Hi everyone, I am trying to use loop (for loop but can be any loop) which will read from the file (text file) which will have 2 column one for account and another for server which kind of look like this
account1 server1
account2 server2
account3 server1
account4 server1
5 server3
6 server2... (1 Reply)
Hi Everybody,
I am bit new to shell scripting. I need some help in my script.
I have to login into 15 servers and check some logs daily. For that I've written one shell script, somewhere it is having some problems. After log into the first server, the script is not going with the next steps.... (6 Replies)
Hi,
I have got a shell script, which fails to run properly..
I am getting the following error:
"Pseudo-terminal will not be allocated because stdin is not a terminal.
Permission denied (gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive)."
I SSH to the machine and then run the... (1 Reply)
Hello,
I am trying to create a matrix of 0's and 1's depending on whether a gene and sample name are found in the same line in a file called results.txt. An example of the results.txt file is (tab-delimited):
Sample1 Gene1 ## Gene2 ##
Sample2 Gene2 ## Gene 4 ##
Sample3 Gene3 ... (2 Replies)
There are 4 remote hosts that I have stored in an array. A ssh trust has been created from the local host to each of the remote hosts.
I am trying to ssh to each of the servers in a for loop as shown below.
declare -a host
host}]="server1"
host}]="server2"
host}]="server3"
... (9 Replies)
Hi,
I want to read file multiple times. Right now i am using while loop but that is not working.
ex.
While read line
do
while read line2
do
echo stmt1
#processing some data based on data.,
done < file2.txt
done < file1.txt # This will have 10... (4 Replies)
Hi,
Apologies if this belongs in the beginner area.
So.. The server I need to log into only allows logins from certain IP addresses. One of those IP's is my home computer, I can easily ssh into my home computer from elsewhere, and would then try to login to my work computer from there, but it... (1 Reply)
Hi ,
Can any please help the below requirement on all multiple servers and multiple dbs.
update configuration set value='yes' ;1)
the above statement apply on 31 Databases at a time on different Ip address
eg : 10.104.1.12 (unix ip address )
the above ip box contains 4 db's eg : db... (2 Replies)