I was hoping to get a little insight into an expect script that I've written.
Basically we have this expect script to perform an sftp upload, key authentication is not an option, and sftp is the only method supported by our vendor, thus the need for this.
I want to be able to catch timeouts and log an error code for scripting purposes.
I need to:
Log into sftp site
Begin Transfer
Detect that upload has hit 100%
If upload does not hit 100% within a certain time, I want to log an error code for scripting purposes.
Here is what I have so far:
I believe the code is working up to the timeout, below is the log from the expect session:
It appears the "quit" is sent twice? Which I guess makes sense b/c it sees the 100% and immediately sends the "quit" before the prompt is ready.
What changes should I make to get my expected results?
Any help would be much appreciated.
On another note, I'd like to expand this expect script, or create another that detects when the DES key has changed, accept it (send yes), and continue.
However I would like to know when this happens, either with an error code, or writing something to a log file...
I've tried the following but it is not working as expected:
The thought was to use the exit codes to determine if the key had to be updated, however it always comes back as exit code 3 (key changed) and didn't send a "yes" when the key actually did change.
If you used sftp with keys, you wouldn't need to install or use a third-party brute-forcing utility to forcefeed plaintext passwords into ssh in an insecure manner for you. "interactive password authentication" means "password typed by a human being in realtime authentication" and nothing else will do. It's so difficult for a reason -- ssh is designed to prevent it, because it's almost impossible to keep unencoded passwords secure, and because allowing them would be just the avenue hackers need to bruteforce your own system or use your system as a platform to bruteforce others.
Google 'passwordless ssh' to find the proper way to do this with keys, there's hundreds of tutorials all over the internet.
I realize this, and do this with some of our other scripts, however as I mentioned this sftp site is hosted by a third party and ssh keys are not an option.
Quote:
Originally Posted by Corona688
If you used sftp with keys, you wouldn't need to install or use a third-party brute-forcing utility to forcefeed plaintext passwords into ssh in an insecure manner for you. "interactive password authentication" means "password typed by a human being in realtime authentication" and nothing else will do.
Google 'passwordless ssh' to find the proper way to do this with keys, there's hundreds of tutorials all over the internet.
I'm not even questioning how to send the password, log in, etc... My question is about error handling with expect. The other parts of the script are already working.
I'm interested in expects ability to see a prompt and send certain text back as a response, and when a prompt is received that is different than what is expected how to handle that.
Quote:
Originally Posted by Corona688
If you used sftp with keys, you wouldn't need to install or use a third-party brute-forcing utility to forcefeed plaintext passwords into ssh in an insecure manner for you. "interactive password authentication" means "password typed by a human being in realtime authentication" and nothing else will do. It's so difficult for a reason -- ssh is designed to prevent it, because it's almost impossible to keep unencoded passwords secure, and because allowing them would be just the avenue hackers need to bruteforce your own system or use your system as a platform to bruteforce others.
Google 'passwordless ssh' to find the proper way to do this with keys, there's hundreds of tutorials all over the internet.
Hello Geeks once more,
Thanks for all the help you have been rendering..
I have a script that depends on the output of an expect statement but sometimes the main script misbehaves which I believe is a result of SSH communication error, how can I apply an error control to know whether the... (2 Replies)
Hi,
I have ftp script like below
How to insert an error handling, If the transfer failed then send mail to me.
Actually, I just need the script to send an email if the FTP failed. How to put the email script within FTP script?
Thank You
Edy (5 Replies)
Hi,
in my bash script I start 3rd party app that runs quickly normally and returns some data that I use later for processing. However if there are problems the app doesn't return anything and just hangs... then my script also hangs of course, awaiting for the app to comeback. Was wondering how to... (3 Replies)
Hi all,
I have some sections of a script that I am trying to add error handling to. Basically if it returns any error, just continue. This is for a deployment script that i am writing to assist in the deployment of scripts out to other systems.
At the top of my KSH script i added this... (5 Replies)
Hi,
I need your guys help again. I run a script which check for some process status in a loop. when i check the process some of the process could throw an error, how can i check that inside my script.
Thanks,
RR (3 Replies)
Hi,
I am trying to write a script to cleanup files in a log directory ..
cd log
find Datk** -mtime +7 -exec rm -f {} \; 2> /dev/null
Have used the above to clean up files in log directory more then 7 days older.
The file can be something like ( auto-generate by some processes and... (2 Replies)
Hi everybody,
We are trying to connect to a server and to a router using an .expect script that automatically authenticate the username and password needed. The error is that we cannot connect to the server using ssh AND we cannot connect to the router using either telnet or go commands from the... (1 Reply)
This Expect script provides expect with a list of IP addresses to Cisco IPS sensors and commands to configure Cisco IPS sensors. The user, password, IP addresses, prompt regex, etc. have been anonymized. In general this script will log into the sensors and send commands successfully but there are... (1 Reply)
Guys,
I'm testing a simple script that connects to a server, does a few checks and sends the results to a file.
code:
#!/bin/ksh
expect <<-EOF | sed 's/^M//' >> file
spawn ssh user@server
expect "password:" { send "password \n" }
expect "$"
send "df -k /dev/md/dsk/d10 |... (4 Replies)