Xshell Forum

Script help

Last post: Tuesday, March 1, 2016 8:08 AM by Simon, 5 reply

 
Monday, February 22, 2016 11:04 AM - Simon

Script help

 
Dears,
I need to make script to open text file and read 1st line only and keep it in memory to reuse after. can you help me how knowing that I know the name of the file already.

Program Ver. : Xshell 5
Wednesday, February 24, 2016 7:19 AM - Simon

Re: Script help

 
any update please ?
Thursday, February 25, 2016 8:43 PM - Support

Re: Script help

 
Try this script below:

Sub Main()
Dim objFile, File, line
Dim objClip

'Read File
Set objFile = CreateObject("Scripting.FileSystemObject")
Set File = objFile.OpenTextFile("\your_path\your_file.vbs", 1)
line = File.Readline
File.Close

'Save ClipBoard
set objClip = CreateObject("htmlfile")
objClip.parentWindow.clipboardData.SetData "text", line

xsh.dialog.msgbox("'"&line&"' copied to the system clipboard")
End Sub

Technical Support

Like us on Facebook
Follow us on Twitter
Visit our blog Blog
Sunday, February 28, 2016 10:22 AM - Simon

Re: Script help

 
when i run the script I get error "file not found" while file in the dir

'Read File
Set objFile = CreateObject("Scripting.FileSystemObject")
Set File = objFile.OpenTextFile("filename.txt", 1)
line = File.Readline
File.Close

I need to check the file is Exists first too.
I run the script over AIX 7.1 from xshell

Thanks in advance for your support.
Monday, February 29, 2016 10:58 PM - Support

Re: Script help

 
The absolute path is required. That should resolve the error. Let me know if it works.

Technical Support

Like us on Facebook
Follow us on Twitter
Visit our blog Blog
Tuesday, March 1, 2016 8:08 AM - Simon

Re: Script help

 
Dears,
I used the full path with same error but when I changed the path to windows and try the code run with No problems so what i figure that VBS can't check the path over AIX or can't find it Kindly if you have any work around provide it to me Thanks i advance. waiting for your reply.