I'm using redhat and have an odd issue with a nested ssh call.
what this is doing is checking if a complete file is in an outbox, if so, ssh to a transfer server, executing a second ssh and checking if a file is 'not' present on the destination and if no, sending the files. I'm restricted to which ids and servers can be used, hence this convoluted method.
I'm getting a syntax error on the part where I'm checking if the file doesn't exist on the target.
Any ideas how to check this in an embedded ssh call?
Thanks in advance
---------- Post updated at 10:19 AM ---------- Previous update was at 10:13 AM ----------
doh... missed a space at the end before ]]
only when I posted it here was it obvious.
Last edited by say170; 10-23-2014 at 12:15 PM..
Reason: added some CR to code to improve readability
If you tunnel to this machine a lot, did you know you can setup ssh to do it for you.
So lets say this machine 10.0.0.1 is called saysdata.
If you put something like the below in your ~/.ssh/config file:
I haven't tried this with alternate identityfiles and this will require you to bring the sftp-key to your local machine. Perhaps someone with more experience in this area knows of a way to keep the identity file on the jump box.
Anyway the result should be that you will be able to simply type:
Without worrying about identity files or nested ssh and scp commands. Much easier and probably worth a little mucking around to get working if you do it semi-regular.
Note that ssh is running a shell on the remote end, so the rules are most likely bash or ksh as sh does not do [[]], but not ssh. I guess 'ssh' as 'secure shell' is a misnomer, since it is not a shell but a remote execution tool.
Hi,
i want use this Comand for my psql request
sh ssh -o StrictHostKeyChecking=no rootatemailaddress.de sudo psql -U postgres -c "select pg_terminate_backend(pid) from pg_stat_activity where datnam=\'$DB\';"'"
but the shell lost the inverted comma for datnam=\'$DB\'. The request deliver... (2 Replies)
Hi there,
I am sorry to ask that kind of beginner thing, but all the code I found online didnt work for me.
All I want to do is: Check via SSH if a File exists on my webserver. The SSH login has to be with username and password.
So I would be very thankful if somebody could write the line.... (8 Replies)
Hi,
I want to validate ssh connection one after one for multiple servers..... password less keys already setup but now i want to validate if ssh is working fine or not...
I have .sh script like below and i have servers.txt contains all the list of servers
#/bin/bash
for host in $(cat... (3 Replies)
Hi All,
I am facing a problem while checking for existence of file over ssh !
Basically, i want to ssh and check if file exists.. If file exists return 1. If file does not exits return 0 (or any value)
I am using the below code
file_avail=`ssh username@host "if ]; then exit 1;... (10 Replies)
Hi everyone,
I am trying to figure out a way to ssh to remote server and check if file exists, and if it doesn't I want to leave the script with an exit status of 5.
I have the following that I am attempting to use, but it is not returning anything:
check()
{
ssh ${SOURCE_SERV} "ls -l... (4 Replies)
Hi
#Testing for file existence
if ; then
echo 'SCHOOL data is available for processing'
else
echo 'SCHOOL DATA IS NOT AVAILABLE FOR PROCESSING'
:
i wrote a script, where it begins by checking if file exists or not.
If it exists, it truncates the database... (2 Replies)
Hi guys!
I'm working on a little script. I have a txtfile with several hosts, Unix team has copied my keys into several of those servers, but not all of them, I need to figure out which ones I don't have access to, (I want a list of servers I don't have access to, so I can request for it). This... (1 Reply)
I am using Net::SSH::Expect to connect to the device(iLO) with SSH. After the $ssh->login() I'm able to view the prompt, but not able to send any coommands.
With the putty I can connect to the device and execute the commands without any issues.
Here is the sample script
my $ssh =... (0 Replies)
I've script where i check connection to many hosts ... it take input from HOSTLIST.txt
Ex. cat HOSTLIST.txt
host1
host2
while read HOSTNAME
do
echo $HOSTNAME
ssh -o "BatchMode=yes" ${HOSTNAME} "echo 2>&1" $$ echo flag=0 || flag=1;
if ; then
echo "No SSH... (3 Replies)