The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > Windows & DOS: Issues & Discussions
.
google unix.com



Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
need script to connect sftp servers kittusri9 Shell Programming and Scripting 1 05-10-2008 05:13 AM
how to connect sftp server using script kittusri9 Shell Programming and Scripting 1 05-06-2008 07:12 AM
how to connect to windows from unix ? guhas Shell Programming and Scripting 2 12-19-2005 05:37 PM
Connect from Windows Using SSH aldowsary AIX 12 08-07-2005 03:12 PM
How do I connect windows xp to Linux Red hat unix TRUEST UNIX for Advanced & Expert Users 7 11-21-2002 12:02 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-12-2008
mohantmk mohantmk is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 9
How to connect SFTP(Linux) from Windows DOS

I need to write a batch script for file transfer from SFTP to Windows system. SFTP is on Linux system. I kept this code in batch file and executing it.. but not working.. Even i tried from Command prompt like this "open sftp.host.com" but getting error. Can anyone help with the code and tell me how to connect SFTP from command prompt.

Here is my sample code,

open sftp.host.com
<username>
<password>
lcd <test/test/../>
cd /test/test/test/
get test.txt
quit

--
Thanks,
Mohan
  #2 (permalink)  
Old 11-12-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
You need an SFTP-compatible executable on the Windows side. You can try the psftp.exe that comes with PuTTY. You would store the SFTP commands in a file, say sftpcommands.txt, and use psftp.exe -b sftpcommands.txt.
  #3 (permalink)  
Old 11-12-2008
mohantmk mohantmk is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 9
Quote:
Originally Posted by Annihilannic View Post
You need an SFTP-compatible executable on the Windows side. You can try the psftp.exe that comes with PuTTY. You would store the SFTP commands in a file, say sftpcommands.txt, and use psftp.exe -b sftpcommands.txt.
I installed Putty with psftp.exe, and kept my scripts in sftpcommands.txt.
I went to command prompt and psftp.exe -b sftpcommands.txt, but it is i am getting this error "'pstfp.exe' is not recognized as an internal or external command, operable program or batch file".

If i open but psftp.exe, it is asking for hostname, login and password. Which is working fine. Can you tell me how to execute that above command which you gave.

--
Thanks,
Mohan Tummalapalli
  #4 (permalink)  
Old 11-13-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
You will either need to add it to your PATH, or specify the full path to the location of the psftp.exe, e.g. "C:\Program Files\PuTTY\psftp.exe" -b "C:\Documents and Settings\Mohan\My Documents\sftpcommands.txt".
  #5 (permalink)  
Old 11-18-2008
mohantmk mohantmk is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 9
Thanks it works. I can run my scripts using "C:\Program Files\PuTTY\psftp.exe" -b "C:\Documents and Settings\Mohan\My Documents\sftpcommands.txt".

I have another doubt it the same script, I need to rename file which iam getting from SFTP, i am not sure the file name which iam getting so iam using "*" but as example iam sending this "ren Test*.txt Test123.txt"

Can you tell me how to rename with date format something like test123[DDMMYYYY][time].

--
Thanks,
Mohan
  #6 (permalink)  
Old 12-20-2008
ilan ilan is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 101
Quote:
Originally Posted by mohantmk View Post
Thanks it works. I can run my scripts using "C:\Program Files\PuTTY\psftp.exe" -b "C:\Documents and Settings\Mohan\My Documents\sftpcommands.txt".

I have another doubt it the same script, I need to rename file which iam getting from SFTP, i am not sure the file name which iam getting so iam using "*" but as example iam sending this "ren Test*.txt Test123.txt"

Can you tell me how to rename with date format something like test123[DDMMYYYY][time].

--
Thanks,
Mohan
Mohan, am i late..?

ren Test*.txt "Test%Date:/= % %Time::=.%.txt"

--ilan
  #7 (permalink)  
Old 11-18-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Thsi isn't really a Unix related question, is it? :-)

Windows batch/command/cmd.exe scripting is one of the most ridiculous languages I have ever encountered. Anyway, something like this might work for you:

Code:
for /f "tokens=1-3 delims=/ " %d in ('date /t') do ren test*.txt test%d%e%f.txt
Closed Thread

Bookmarks

Tags
sftp, sftp windows

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0