Non-interactive FTP within SSH session not working
Hello everyone!
I am trying to log-in to a remote server over SSH, transfer file1 there, perform some checks, capture the results in file2 and transfer file2 back to my local server - all of this non-interactively. Initially, I tried to do this within a singe SSH session, using the following code --
While running this piece, I find that the process is stuck after the "bye" in the first FTP sequence. The script is not executing anything after that. So, to troubleshoot, I tried putting the first FTP in one SSH session, and everything after that in another. This time the FTP prompt is getting terminated properly, and the second SSH connection is also successful, but the error being thrown is -
Quote:
ksh[2]: syntax error in line 3: ']]' unexpected
I guess putting all the separate sections of my code (i.e., the first FTP, the checking and the 2nd FTP) in separate SSH sessions would resolve this issue, however, it might not be preferable, as this is part of a much-larger program, which I'm trying to keep as light as possible.
I'm doing this on Solaris platform, using KSH. I've also checked and confirmed that my default shell in the remote host is KSH (though, I'm not sure if that would make any difference).
First off, realize that whitespace may get flattened by cramming it all into one giant "" like that over ssh. It may be treating newlines just as whitespace and cramming multiple lines together. A here-document wouldn't do that, but then you'd be making here documents inside here documents...!
Might be time to put all that into a script of its own:
ARG1 will be available as $1, ARG2 as $2, etc if you need to pass values into the remote shell.
I fire the rsyn command as below:
rsync --delay-updates -F --compress --archive -e "/usr/bin/ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" user1@myhost.server.com:/tmp/jarexplorer-0.7.jar /web/admin/data/ The above command get interpreted as below: ssh -vvv -o... (4 Replies)
Inorder to make the pkgadd non-interactive i tried couple of things but both failed.
1.
sudo pkgadd -n /u/mont/admin -d /u/mont/dbprd.pkg
pkgadd: ERROR: no packages were found in </var/spool/pkg>
2.
yes all | sudo pkgadd -a /u/mont/admin -d /u/mont/dbprd.pkg
... (0 Replies)
Hi, I'm experiencing an issue with creating an ftp session via cron.
I am creating an ftp session between a data server and a reporting tool. I have created the script wherein the data server begins the ftp session and puts files into the tool.
I have used the .netrc files for this and I run... (10 Replies)
Hello,
I'm looking to script the basic instant messaging program we have in my company, it's called "oi", it's working as follow:
# oi $user
then we have to launch it...
after finding the system of the user it's asking for the message...
then on a new line we have to hit ctrl+d
I... (2 Replies)
Hi,
I want to know how to use SSH non-interactively? I am already able to use sftp -b <batch file> user@host so public/private key set-up already is in place.
But my supervisor has told me to use SSH now I want to know how it can be done? I want to do something like:
done_files=`ssh ls... (7 Replies)
I am writing an automation that will ssh into hundreds of system and run a few commands. I ll be looping from ip X.X.X.10 to X.X.X.200
I have public key set up ready for "most" of them to run ssh non interactively. However some of the systems in these ip range do not have the public private key... (2 Replies)
Hi,
I am changing the login authentication method from password to keyboard interactive for security purposes. I know this option is kind of add-on for ssh client programs; which explains the best info about option is in this link:
User Authentication with Keyboard-Interactive :eek:
One of... (4 Replies)
Our network administrators implemented some sort of check to kill idle sessions and now burden is on us to run some sort of keep alive. Client based keep alive doesn't do a very good job. I have same issue with ssh. Does solution 2 provided above apply for ssh sessions also? (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)
Hi All,
I'm trying to get this to work but when I execute it I get the following error
./ftp_upload.sh: line 78: syntax error: unexpected end of file.
This was working before I expanded the script and had the here document part directly below within a function.
Can anyone spot what I've... (5 Replies)