|
#1
|
|||
|
|||
![]()
Good day... I am trying to open a new tab via Javascript for SFTP. I have used the vbscript guide example as a basis, but it is not working. It would be great if there were a version of that guide in JS to use!
In any case, here is what I have, any insights would be greatly appreciated! Code:
// SFTP test var objTab; var objSFTPTab; objTab = crt.Session.ConnectInTab("/S"); //objTab.Caption = "New SFTP Tab"; // Create an SFTP tab associated with the existing tab objSFTPTab = objTab.ConnectSFTP(); // Wait for the SFTP tab to be ready for input. objSFTPTab.Screen.Synchronous = true; crt.Sleep(1000); objSFTPTab.Screen.Send(String.fromCharCode(13)); objSFTPTab.Screen.WaitForString("sftp>"); // Upload all .txt files in the current local working directory to // the current remote working directory. objSFTPTab.Screen.Send("put *.txt" + String.fromCharCode(13) + String.fromCharCode(10)); objSFTPTab.Screen.WaitForString("sftp>"); // Close the SFTP tab objSFTPTab.Close(); // Close the connection on the originating SSH2 connection's tab objTab.Session.Disconnect(); |
#2
|
|||
|
|||
Hi mschaafs,
What version of SecureCRT are you using? On what platform/OS? Your code worked for me with one minor change. You are not specifying a session to be opened. If you want to just make an ad hoc connection, then use /SSH2 hostname instead of /S SessionName: Code:
objTab = crt.Session.ConnectInTab("/S SessionName"); I am not sure a manual on JScript is ever feasible (Python would be the next one up), but I have added this thread to a feature request in our product enhancement database for more JavaScript examples. Should a future release of SecureCRT include this feature, notification will be posted here. If you prefer direct email notification, send an email to support@vandyke.com and include "Feature Request - Forum Thread #12935" in the subject line or use this form from the support page of our website.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
![]()
Yes! Thank you Brenda... Using a new login connection worked... but now I have to deal with the password, but I will get that figured out.
I am using version 8.1.4 build 1443. One weird thing I am seeing, is that I have to send a command that appears not to be working in order to send one that does work. See below, I have the 'lpwd' command being sent twice, because the first one doesn't show up. Also, is there a command to force a disconnect without a prompt? Code:
// SFTP test var objTab; var objSFTPTab; objTab = crt.Session.ConnectInTab("/SSH2 /L user /PASSWORD pw host"); objTab.Caption = "Connection Tab"; objTab.Screen.Synchronous = true; // Create an SFTP tab associated with the existing tab objSFTPTab = objTab.ConnectSFTP(); objSFTPTab.Caption = "SFTP Tab"; objSFTPTab.Screen.Synchronous = true; crt.Sleep(1000); // Wait for the SFTP tab to be ready for input. objSFTPTab.Screen.Send(String.fromCharCode(13)); objSFTPTab.Screen.WaitForString("sftp>"); // Send extra command to prompt to activate, for whatever reason... is required. objSFTPTab.Screen.Send("lpwd" + String.fromCharCode(13)); objSFTPTab.Screen.WaitForString("sftp>"); objSFTPTab.Screen.Send("lpwd" + String.fromCharCode(13)); objSFTPTab.Screen.WaitForString("sftp>"); objSFTPTab.Screen.Send("lcd newLocalPath" + String.fromCharCode(13)); objSFTPTab.Screen.WaitForString("sftp>"); objSFTPTab.Screen.Send("get fileNameHere" + String.fromCharCode(13)); objSFTPTab.Screen.WaitForString("sftp>"); // Close the SFTP tab objSFTPTab.Close(); // Close the connection on the originating SSH2 connection's tab objTab.Session.Disconnect(); objTab.Close(); |
#4
|
|||
|
|||
Hi mschaafs,
Quote:
Quote:
Quote:
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 Last edited by bgagnon; 12-08-2017 at 03:41 PM. |
#5
|
|||
|
|||
Hi mschaafs,
I took out the extra lpwd and get everything just as expected (I had commented out the disconnect/close): Code:
sftp> sftp> lpwd C:\Users\user\Documents sftp> lcd .. sftp> get testfile.txt Downloading testfile.txt from /home/user/testfile.txt 100% 38KB 38KB/s 00:00:00 /home/user/testfile.txt: 39596 bytes transferred in 0 seconds (38 KB/s) sftp>
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#6
|
|||
|
|||
![]()
Hi! Thank you gain for the speedy response!
One weird thing I am seeing, is that I have to send a command that appears not to be working in order to send one that does work. Quote:
Quote: Also, is there a command to force a disconnect without a prompt? Quote:
|
![]() |
Tags |
file transfer , javascript , scripting , session tabs , sftp |
Thread Tools | |
Display Modes | |
|
|