 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
felixc
Joined: 24 Sep 2007 Posts: 20 Country: Hong Kong |
|
How to copy a file at remote computer |
|
Hi,
I was writing a script to send an email attached with a file at remote computer, a log file at our database servers.
My script coded like this
Set ( attachment, "\\servername\dir_name\filename.txt")
MailSendWithAttachment(..., attach...)
But I got an error says that the file specified is not accessible.
Then I try to use FileCopy to copy the file to a local directory but got same error message. It seems that the software recognised an invalid file name due to the escape character.
Please advise how to specify a file at remote computer. I cannot map it as a network drive.
|
|
Thu Sep 27, 2007 5:27 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7962
|
|
|
|
Hi,
"\" is a default escape character. Please see FAQ or Special ASCII symbols in the on-line help for more details. If you want to use it is a literal you must double it.
 |
 |
Set ( attachment, "\\\\servername\\dir_name\\filename.txt") |
|
|
Thu Sep 27, 2007 9:24 am |
|
 |
felixc
Joined: 24 Sep 2007 Posts: 20 Country: Hong Kong |
|
Another error message |
|
Hi,
I tried your suggestion but got another error message. "Error reading "file name".
The string in the "file name" is correct and I can open it with a notepad at same workstation.
Please advise.
Felix
|
|
Thu Sep 27, 2007 10:32 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7962
|
|
|
|
Please let us review your code. We are unable to help you if we don't know what you are doing. If your code contains sensitive information such as email addresses and/or passwords, replace them with asterisks or other wildcards, but please keep your file names as is, so we can see the problem.
|
|
Thu Sep 27, 2007 10:37 pm |
|
 |
felixc
Joined: 24 Sep 2007 Posts: 20 Country: Hong Kong |
|
My code |
|
Hi,
Thanks for help.
===============================================
Dim Sender, string
Dim Recipients, string
Dim Subject, string
Dim Message, string
Dim Attach, string
Dim Current_time, time
Dim Time_string, string
Now( current_time )
Format( current_time, "hh:mm:ss", Time_string)
Set( Sender, "Job.IT")
Set( Recipients, "*****@*****.**")
Concat( "System log of Rep Server of AMC at ", time_string, Subject )
Set( Message, "System log from AMC Portia server.\n")
Set( Attach, "\\\\portia_ad\\RepLog\\PRS.log")
MailSendWithAttachment( Sender, "", Recipients, Subject, Message, Attach )
=========================================================
Felix
|
|
Thu Sep 27, 2007 10:45 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7962
|
|
|
|
Please try the following. I simplified you script to make it more readable, and added file copy to local folder, so that MailSend… can use a local file (I don't think email attachments can refer to UNC names).
I added line wrapping options only because the web page will wrap the long line and it can split it in wrong places.
 |
 |
FileCopy( "\\\\portia_ad\\RepLog\\PRS.log", "C:\\temp\\PRS.log" )
MailSendWithAttachment( "Job.IT", "", "*****@*****.**", &
"System log of Rep Server of AMC at @T"hh:mm:ss"", &
"System log from AMC Portia server.", &
"C:\\temp\\PRS.log" )
FileDelete( "C:\\temp\\PRS.log" ) |
|
|
Thu Sep 27, 2007 11:44 pm |
|
 |
felixc
Joined: 24 Sep 2007 Posts: 20 Country: Hong Kong |
|
The problem is fixed. |
|
Thank you
|
|
Fri Sep 28, 2007 1:50 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|