Bookmark and Share

Author Topic: Odd Win7 connex issue (FTP, WinSCP, PuTTY) ::RESOLVED::  (Read 7162 times)

0 Members and 1 Guest are viewing this topic.

Offline IFE-ENG

  • PcWinTech Jr. Member
  • Join Date: Feb 2013
  • Posts: 4
  • Karma: 0
Odd Win7 connex issue (FTP, WinSCP, PuTTY) ::RESOLVED::
« on: February 28, 2013, 04:57:13 PM »
I have searched in many forums and Google and have not seen anyone else mention this issue. So I hope I just missed it and someone can help. This issue I am encountering is this:

Whether I use WinSCP, puTTY or FTP in Windows CMD (command line), the first time I try and connect, it fails, but if I re-run the same command line or GUI setup, it will connect to my UUT (Unit Under Test). And this odd sequence will continue in an odd/even way. Meaning, if I close the successful (2nd try) and try a 3rd time (with the exact same command line or program setup) it will fail. But when I re-run the 4th time (same commands) it will connect. And on and on.

My setup is: I am using a PC with Win7 and connecting to a UUT (Unit Under Test) running Linux, on a closed network (not connected to the internet) through a Ethernet hub. All Firewalls are turned off (this is a test bench setup and not connected to the internet or any other computer network). I do not know if this occurs on any other Windows OS like XP.

My goal is to run some batch files to automate an FTP sequence, then put some files on the UUT. I also use puTTY to Telnet in and run test scripts on the UUT. I have successfully run some batch files but only in this strange fail/pass/fail/pass way.

This is an example of my code:
**File upload_patch.bat**
@ECHO OFF
cd\Users\lab\Desktop\
ftp -s:ftp.txt
call plink.bat
PAUSE
  ***File ftp.txt***
  open 172.21.100.101
  user
  password
  cd /
  mkdir temp
  cd /temp
  lcd C:\SVDU-3W_Test\patch
  mput svdu3*.*
  y
  y
  quit
****File plink.bat****
@ECHO OFF
cd\Users\lab\Desktop\
plink.exe user@172.21.100.101 -pw password chmod 755 /temp/svdu3*
plink.exe user@172.21.100.101 -pw password PATH=$PATH:/bin;/temp/svdu3_BIOS_recovery_util.sh

« Last Edit: March 07, 2013, 04:07:07 PM by IFE-ENG, Reason: solution found »

PcWinTech.com Forums

Odd Win7 connex issue (FTP, WinSCP, PuTTY) ::RESOLVED::
« on: February 28, 2013, 04:57:13 PM »

Offline Shane

  • Top Geek, err uh Dog.
  • PcWinTech Administrator
  • PcWinTech Guru
  • *******
  • Join Date: Jul 2008
  • Posts: 16,846
  • Location: USA
  • Karma: 523
  • "Knowledge should be shared not hidden."
Re: Odd Win7 connex issue (FTP, WinSCP, PuTTY)
« Reply #1 on: February 28, 2013, 05:28:50 PM »
I dont have an answer of the fail/pass/fail, but as a programmer I know what I would do if I encountered this.

We need to put some error handling int he bat file, so when it fails the first time it will automatically try again.

You can use a if statment to see if it connects and then based on if it does or not use the goto commands to go to different sections in the bat file. So when it fails you can send it back to itself to try again (But might it stuck trying forever if it always fails) or have it go to another attempt and once it does connect the goto will then run the proper commands you need.

Do you know how to do this? If nto I can make an example of the if and goto statements. :wink:

Shane
(My weekends belong to my wife and kids, I will try my best to answer all posts daily during the work week)

(About Shane)
Site Owner, Top Admin, Lead Programmer, Wife & 5 kids, Needs a lot more coffee.

When people ask "Why fix what isn't broken?" I reply "To make it better."
"Only a life lived for others is a life worthwhile"
Honor & Respect is all that matters.

Owner & Programmer of: www.pcwintech.com & www.tweaking.com

Offline IFE-ENG

  • PcWinTech Jr. Member
  • Join Date: Feb 2013
  • Posts: 4
  • Karma: 0
Re: Odd Win7 connex issue (FTP, WinSCP, PuTTY)
« Reply #2 on: March 01, 2013, 01:19:20 PM »
Thank you Shane for your response. I think I'd be able to put together the IF THEN type of statements. Maybe even add in a FOR I = n line to limit the number of retries as you mentioned the infinite loop issue. Where I'm stumped to begin with is, what error flag am I going to be looking for to know if the connection did not occur? Once I know that variable to use, I think I can smash together some code to check it and do a retry depending on it's value.

I've attached a screen shot of the CMD window when it fails just for reference.

Offline Shane

  • Top Geek, err uh Dog.
  • PcWinTech Administrator
  • PcWinTech Guru
  • *******
  • Join Date: Jul 2008
  • Posts: 16,846
  • Location: USA
  • Karma: 523
  • "Knowledge should be shared not hidden."
Re: Odd Win7 connex issue (FTP, WinSCP, PuTTY)
« Reply #3 on: March 01, 2013, 01:22:57 PM »
These should help you

http://ss64.com/nt/for_f.html
and
http://ss64.com/nt/if.html

And you will want to set a variable so you can have it hit if it was successful or not and then what to do based on that

http://ss64.com/nt/set.html

Shane
(My weekends belong to my wife and kids, I will try my best to answer all posts daily during the work week)

(About Shane)
Site Owner, Top Admin, Lead Programmer, Wife & 5 kids, Needs a lot more coffee.

When people ask "Why fix what isn't broken?" I reply "To make it better."
"Only a life lived for others is a life worthwhile"
Honor & Respect is all that matters.

Owner & Programmer of: www.pcwintech.com & www.tweaking.com

Offline IFE-ENG

  • PcWinTech Jr. Member
  • Join Date: Feb 2013
  • Posts: 4
  • Karma: 0
Re: Odd Win7 connex issue (FTP, WinSCP, PuTTY)
« Reply #4 on: March 07, 2013, 10:41:13 AM »
Shane, thanks for those links. I actually didn't see your post until now. So I will check those out. So I wanted to post what I came up with to resolve this strange issue I am seeing (Windows7 fails to connect FTP first time). The two main files are below (one batch and one ftp command file).

****upload_patch.bat****
@ECHO OFF
cd\Users\lab\Desktop\
ECHO Attempting first try.. please wait 10 seconds
ftp -s:ftp.txt > C:\Users\lab\Desktop\ftplog.txt

findstr /c:"Invalid command" ftplog.txt >NUL
if %ERRORLEVEL% == 1 (
    echo Connection: PASSED
) else (
    echo Connection: FAILED
    echo Retrying now...
    ftp -s:ftp.txt
)
del ftplog.txt
call plink.bat
PAUSE

****ftp.txt****
open 172.21.136.143
root
root00
cd /
mkdir temp
cd /temp
lcd C:\SVDU-3W_Test\patch
mput svdu3*.*
y
y
quit


The solution I used was to output the STDOUT of the FTP command into a file (ftplog.txt). When the FTP fails to connect there are a bunch of "Invalid command" responses. So I use a FINDSTR command to look for that and use the %ERRORLEVEL% and an IF ELSE statement to either retry the FTP command (which always works on the 2nd and even tries) or a pass condition.

I hope this helps.

Offline Shane

  • Top Geek, err uh Dog.
  • PcWinTech Administrator
  • PcWinTech Guru
  • *******
  • Join Date: Jul 2008
  • Posts: 16,846
  • Location: USA
  • Karma: 523
  • "Knowledge should be shared not hidden."
Re: Odd Win7 connex issue (FTP, WinSCP, PuTTY)
« Reply #5 on: March 07, 2013, 03:56:30 PM »
Nice :-)

That should do the trick, let me know how it ends up working for you. :wink:

Shane
(My weekends belong to my wife and kids, I will try my best to answer all posts daily during the work week)

(About Shane)
Site Owner, Top Admin, Lead Programmer, Wife & 5 kids, Needs a lot more coffee.

When people ask "Why fix what isn't broken?" I reply "To make it better."
"Only a life lived for others is a life worthwhile"
Honor & Respect is all that matters.

Owner & Programmer of: www.pcwintech.com & www.tweaking.com

Offline IFE-ENG

  • PcWinTech Jr. Member
  • Join Date: Feb 2013
  • Posts: 4
  • Karma: 0
Re: Odd Win7 connex issue (FTP, WinSCP, PuTTY)
« Reply #6 on: March 07, 2013, 04:05:00 PM »
It has been working splendidly  :cheesy:

I've been using it along with another similar batch file I wrote to send some shutdown commands, that also fail the first time ran but pass the second. Bizarre  :thinking:

I really wish I knew what was causing the fail/pass/fail/pass syndrome  :confused:

Thanks for the help and links

Offline Shane

  • Top Geek, err uh Dog.
  • PcWinTech Administrator
  • PcWinTech Guru
  • *******
  • Join Date: Jul 2008
  • Posts: 16,846
  • Location: USA
  • Karma: 523
  • "Knowledge should be shared not hidden."
Re: Odd Win7 connex issue (FTP, WinSCP, PuTTY) ::RESOLVED::
« Reply #7 on: March 07, 2013, 04:15:18 PM »
No problem and good to hear you are working good :-)

Shane
(My weekends belong to my wife and kids, I will try my best to answer all posts daily during the work week)

(About Shane)
Site Owner, Top Admin, Lead Programmer, Wife & 5 kids, Needs a lot more coffee.

When people ask "Why fix what isn't broken?" I reply "To make it better."
"Only a life lived for others is a life worthwhile"
Honor & Respect is all that matters.

Owner & Programmer of: www.pcwintech.com & www.tweaking.com

PcWinTech.com Forums

Re: Odd Win7 connex issue (FTP, WinSCP, PuTTY) ::RESOLVED::
« Reply #7 on: March 07, 2013, 04:15:18 PM »

 

email