Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-30-2020, 12:35 PM
stlmill stlmill is offline
Registered User
 
Join Date: Feb 2017
Posts: 4
Can't find file on remote system

Is there something that needs to be active on a remote system to allow, objFSO.OpenTextFile to find the file? This works fine on my local PC but, gives file not found on remote.

Any help would be greatly appreciated!!

Remote system is using SecureCRT

Code:
Option Explicit

Dim strError
Dim objFSO
Dim objFile
Dim strLine
Dim intResult

CONST ForReading = 1 'Open text file to Read.

strError = "value" 'searching for Error in log file.

crt.Dialog.MessageBox(strError)

Set objFSO = CreateObject("Scripting.FileSystemObject")' Allows talking to the filesystem.
Set objFile = objFSO.OpenTextFile("C:\ID3.txt", ForReading) 'Opens text file to Read

	strLine = objFile.ReadLine 'Tells Script to read one line from the text file referenced in objFile


Do Until objFile.AtEndofStream 'In effect until the End of stream is reached
	
	strLine = objFile.ReadLine 'Reads lines text, one line at a time, until the end to the text string is reached.Use to supply text for  the Do Until Loop
	
	intResult = InStr(strLine, strError) ' Result of Instr command, which looks through a string of text and tries to find the match.
		If intResult <> 0 Then 'Instr only returns a number, there's a table that shows what the number means. Pg 46 table 2-1
		
		crt.Dialog.MessageBox(strLine) 'Shows the string line of text with the Error.
		
	End if
Loop
crt.Dialog.MessageBox ("all done")
objFile.Close

Last edited by jdev; 03-30-2020 at 04:15 PM. Reason: Wrap code in [CODE][/CODE] blocks so that it maintains formatting.
Reply With Quote
  #2  
Old 03-30-2020, 05:45 PM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 338
Hi stlmill,

If the same *exact* script code works on the local computer, but fails with "file not found" error when the same exact script code is run on the remote computer, then it must mean that the file named "ID3.txt" does not exist on the remote computer at the location C:\.

If you open File Explorer (explorer.exe) on the remote machine and navigate to C:\, is there a file there named "ID3.txt"?

If you do see the file and you are still getting this error when running the script in SecureCRT, it *could* be possible that SecureCRT on the remote machine is running in a "published" mode with a virtualized environment in which you do not have access to the full file system -- only a well-defined "sandbox", if you will.

One way to find out if this might be the case is to remove all SecureCRT scripting elements from the script (it's not doing anything that *REQUIRES* SecureCRT at this point).
Code:
Option Explicit

Dim strError
Dim objFSO
Dim objFile
Dim strLine
Dim intResult

CONST ForReading = 1 'Open text file to Read.

strError = "value" 'searching for Error in log file.

MsgBox strError

Set objFSO = CreateObject("Scripting.FileSystemObject")' Allows talking
to the filesystem.
Set objFile = objFSO.OpenTextFile("C:\ID3.txt", ForReading) 'Opens text
file to Read

    strLine = objFile.ReadLine 'Tells Script to read one line from the
text file referenced in objFile


Do Until objFile.AtEndofStream 'In effect until the End of stream is reached
   
    strLine = objFile.ReadLine 'Reads lines text, one line at a time,
until the end to the text string is reached.Use to supply text for  the
Do Until Loop
   
    intResult = InStr(strLine, strError) ' Result of Instr command,
which looks through a string of text and tries to find the match.
        If intResult <> 0 Then 'Instr only returns a number, there's a
table that shows what the number means. Pg 46 table 2-1
       
        MsgBox strLine 'Shows the string line of text with the Error.
       
    End if
Loop
MsgBox "all done"
objFile.Close
If you take all of the SecureCRT components out of the script, and the script runs successfully on both the local and the remote system, then it leads one more towards the idea that SecureCRT is running within a sandbox "published" environment.

If the same SecureCRT-less script runs outside of SecureCRT successfully on the local machine, but fails in the same way on the remote machine, then it proves that the file doesn't exist in C:\.

Is this information helpful?
__________________
Thanks,
--Brittney

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 03-31-2020, 06:50 AM
stlmill stlmill is offline
Registered User
 
Join Date: Feb 2017
Posts: 4
Thanks for your help.

Brittney

Thank you for your quick response.

I've tried the code you suggested and it still can't find the file. I created the file and can view the file using TelnetSSh2. I don't have an explanation of why other than the system uses White Listing for virus protection. With the White Listing you can't copy to the system, but I'd hoped the opening the file would work. Thanks again for your help.
Reply With Quote
  #4  
Old 03-31-2020, 11:12 AM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 338
Hi stlmill,

I am glad to hear that you were able to rule out SecureCRT and get some clarification about what might be causing the behavior! Have a great day!
__________________
Thanks,
--Brittney

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump


All times are GMT -6. The time now is 12:29 AM.