# Solved: Encountering errors when trying to automate PSFTP command using a .bat file



## savoym (Aug 19, 2013)

In looking at other posts, "http://stackoverflow.com/questions/16439039/batch-file-for-putty-file-transfer-automation", regarding automating the PSFTP command in a .bat file so that I can setup a Windows Scheduled Task, I tried the following but got the error below:

In the .bat file that I'm executing I have the following lines:


```
@echo off
    cd "c:\PuTTY"
    psftp 999.99.999.999 -l XXXXXIO -i testGSX.ppk -b DownloadDiscoverReports.txt
```
In the DownloadDiscoverReports.txt file I have the following lines:


```
lcd c:\Reports\GSXDLFILES\ALLRPTS
    cd /DSCVROUT/ALLRPTS/
    mget *ALLRPTS%POLLABLE*
    lcd c:\Reports\GSXDLFILES\XMIT81
    cd /DSCVROUT/XMIT81/
    mget *XMIT81%POLLABLE*
```
The error I'm getting when I execute the .bat file from my C:\ is:


```
C:\>gsx_dl.bat
    psftp: no hostname specified; use "open host.name" to connect
    New local directory is c:\Reports\GSXDLFILES\ALLRPTS
    psftp: not connected to a host; use "open host.name"
    
    C:\PuTTY>
```
Any suggestions/direction on how to fix this issue would be appreciated. Thank you.


----------



## savoym (Aug 19, 2013)

So just to clarify. When I execute the psftp command from the c:\putty command prompt that is in my .bat file above, it works great. I've tried modifying the psftp command to include the word "open" right before the IP address (host) but I still get the same error. 

 

Again, any help/direction would be appreciated. Thanks.


----------



## savoym (Aug 19, 2013)

After a reply from PUTTY support, stating to enter a -v to view more detail, I was able to see that my key had expired. The syntax of the command is fine which was my question. Problem fixed.


----------

