My script is working so far to open a remote FTP connection, change directory, and download a file. My last two steps would be to delete the remove file once it's fully downloaded and then close the connection. ACF documentation (and cfdocs) seems to have very little information on this. Here's what I have so far:
ftpConnection = ftpService.open(
action = 'open',
connection = variables.ftpConnectionName,
server = variables.ftpServerName,
username = '***************',
password = '***************',
secure='true');
if( ftpConnection.getPrefix().succeeded ){
fileList = ftpService.listdir(directory = variables.ftpPath, connection= variables.ftpConnectionName, name='pendingFiles', stopOnError='true').getResult();
if( fileList.recordCount ){
changeFtpConnectionDir = ftpService.changeDir(
connection = variables.ftpConnectionName,
directory = variables.ftpPath);
getFtpConnection = ftpService.getFile(
connection = variables.ftpConnectionName,
remoteFile = fileList.name,
localFile = local.localPath & fileList.name,
failIfExists = false,
timeout = 3000
);
deleteRemoteFile = ftpService.remove(
connection = variables.ftpConnectionName,
remoteFile = fileList.name
};
closeFtp = ftpService.close(
connection = variables.ftpConnectionName
);
};
};
Error is thrown on the remoteFile = fileList.name. Since I already changed directory I don't think I need to put the full path here.
I put the entire script up since there doesn't seem to be many resources out there about using the newer ftpServer() functions.
D'oh - my issue was a typo:
deleteRemoteFile = ftpService.remove(
connection = variables.ftpConnectionName,
remoteFile = fileList.name
);// had } instead of )
I'll still leave this up as a resource for ftpService()
Related
IdConnectionInterceptOpenSSL->SSLOptions->Method = sslvSSLv23;
IdConnectionInterceptOpenSSL->SSLOptions->Mode = sslmClient;
IdConnectionInterceptOpenSSL->SSLOptions->VerifyDepth = 0;
//....
TCHAR* SIR = SIRX[ix].c_str();
AnsiString rtf;
TStringStream * Send = new TStringStream(rtf) ;
Send->Write(SIR, (SIRX[ix]).Length()); // <-- new
Send->Position = 0;
TMemoryStream *Receive = new TMemoryStream() ;
AnsiString ADRESA = "https://webservicesp.anaf.ro:443/PlatitorTvaRest/api/v1/ws/tva";
IdHTTP->Request->Accept = "application/json";
IdHTTP->Request->ContentType = "application/json";
IdHTTP->Request->Connection = "Keep-Alive";
IdHTTP->Post(ADRESA, Send, Receive);
If I use a direct Internet connection, it works fine.
My problem appear when I use a proxy server for Internet connection.
I put
IdHTTP->Request->ProxyServer = PROXY_SERVER;
IdHTTP->Request->ProxyPort = StrToInt(PROXY_PORT);
if(PROXY_USER.IsEmpty() == false)
IdHTTP->Request->ProxyUsername = PROXY_USER;
if(PROXY_PASSW.IsEmpty() == false)
IdHTTP->Request->ProxyPassword = PROXY_PASSW;
But the error appears like this : connection closed gracefully to the first interrogation, and after, the same interrogation give 501 Not Implemented.
Where is the problem? Are there any solutions?
Below here is a code snippet what I m trying out:
PRINTER_INFO_2 pi;
BOOL Result = FALSE;
HANDLE pHd;
memset(&pi, 0, sizeof(PRINTER_INFO_2));
pi.pPrinterName = L"RxXPSDrv";
pi.pDriverName = L"XPSDrv Sample Driver";
// Select Share Name
pi.pShareName = L"MyPrinter";
// Select Server Name
pi.pServerName = NULL;
// Select Port Name
pi.pPortName = L"COM3:";
//pi.pPortName = L"C:\\Users\\admin\\Desktop\\a1.xps";
pi.pSecurityDescriptor = NULL;
// Select Print Processor
pi.pPrintProcessor = L"winprint";
// Select Attributes
pi.Attributes = PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST | PRINTER_ATTRIBUTE_LOCAL;
// Set Priority
pi.Priority = 1;
// Call the function AddPrinter
pHd = AddPrinter(NULL, 2, (LPBYTE)&pi);
Here #pi.pPortName I need to provide C:\Users\admin\Desktop\a1.xps but its not working and the printer isn't getting added. With COM3 it works fine.
Can anyone tell me how can I do this? How can I provide full path of a XPS to pi.pPortName?
You have to add a "local port" "C:\Users\admin\Desktop\a1.xps" first. I just tried and it worked. Some code for Add port: Adding-a-Local-Port-through-XcvData-and-C
I'm working on a little e-cards project.
I have to send emails from my remote server with PHPMailer.
localy I'm using this configuration (with my own Gmail email adress) and it works perfectly.
/ssi/mail.config.php
<?php
$mail = new PHPMailer(true);
$mail->CharSet = 'utf-8';
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = '587';
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = 'private#gmail.com';
$mail->Password = '***secret***';
$mail->SMTPSecure = 'tls';
?>
On my remote server (hosted on one.com) I have created an email account for the domain.
I changed the host and the port like the helpdesk said ... but I don't get it to work remotly.
<?php
'ssi/mail.config.php'
$mail = new PHPMailer(true);
$mail->CharSet = 'utf-8';
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'send.one.com';
$mail->Port = '25';
$mail->SMTPSecure = 'none';
$mail->SMTPAuth = true;
$mail->Username = 'ecards#iveweygers.be';
$mail->Password = '***secret***';
$mail->SMTPSecure = 'none';
?>
Thanks again!
Looking at the one.com page, there are a few things wrong with this. For smtp they say to use Port 465 with SSL encryption. So, your code should be:
$mail = new PHPMailer(true);
$mail->CharSet = 'utf-8'; // You can remove this line, utf-8 is the default.
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'send.one.com';
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Username = 'ecards#iveweygers.be';
$mail->Password = '***secret***';
Also worth noting -- and something that it took me a LONG time to find: My SMTP server required authentication to send an email. I assumed that the SMTPAuth = true; took care of that but it did not. I noticed that one.com does as well -- i.e. they tell you to click the button in Outlook that says that your outgoing server requires authentication.
I finally got it to work by putting this at the top of my file:
$pop = new POP3();
$pop->Authorise("send.one.com", 465, 30, "ecards#iveweygers.be", "***secret_password***", 1);
That takes care of the authentication. Then you can jump into the $mail = new PHPMailer(true) and setting all of your parameters and sending the mail.
So your entire file should look like this:
$pop = new POP3();
$pop->Authorise("send.one.com", 465, 30, "ecards#iveweygers.be", "***secret_password***", 1);
$mail = new PHPMailer(true);
$mail->CharSet = 'utf-8'; // You can remove this line, utf-8 is the default.
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'send.one.com';
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Username = 'ecards#iveweygers.be';
$mail->Password = '***secret***';
You have not said how it's failing, which makes diagnosis difficult.
I really wouldn't recommend any service that uses authentication without encryption. There is no meaning to setting SMTPSecure to 'none' - just set it to an empty string (or don't set it at all) if you don't want SSL or TLS, and you only need to do that once (not twice as in your code).
The other solutions did not work for me; this one did:
$mail->isSMTP();
$mail->Host = 'mailout.one.com';
$mail->SMTPAuth = false; // disable SMTP authentication
$mail->Username = '[your one.com-email]';
$mail->Password = '[your one.com-email password]';
$mail->SMTPSecure = ''; // leave this blank!
$mail->Port = 25;
Let me know if it helped you, too!
ะก++, Embarcadero RAD Studio XE2
I need connect to a ::6100 with TIdTCPClient through http-proxy. So I wrote this code:
m_pClient = new TIdTCPClient( NULL );
m_pClient->Host = m_sServerAddress.c_str();
m_pClient->Port = StrToInt( m_sServerPort.c_str() );
m_pClient->ConnectTimeout = 5000;
m_pClient->ReadTimeout = 5000;
if ( m_bUseProxy == true )
{
m_pIdIOHandlerStack = new TIdIOHandlerStack( NULL );
m_pIdIOHandlerStack->TransparentProxy = new TIdConnectThroughHttpProxy( m_pIdIOHandlerStack );
m_pIdIOHandlerStack->TransparentProxy->Host = m_sProxyHost;
m_pIdIOHandlerStack->TransparentProxy->Port = m_iProxyPort;
m_pIdIOHandlerStack->TransparentProxy->Enabled = True;
m_pClient->IOHandler = m_pIdIOHandlerStack;
}
else
{
m_pClient->IOHandler = NULL;
}
<other code>
m_pClient->Connect();
I got an exeption "403 forbidden" on "Connect"
proxy: 5.196.0.118::3128
I can connect to this server without proxy or ping it.
I used this proxy server successfully with my browser, but I can't use it for my code.
How can I resolve this problem?
Experts... I'm creating another question in continuation with my earlier query.... this question is different from earlier request so I thought better to create new thread instead of confusing experts answers.
Below code connects each alias in tnsfile to the database...
1. Is there anyway I can limit each database connection only once and don't allow different alias connecting to the same database again?
I tried using hash but no able to fix this..
use strict;
use warnings;
if /^(([A-Za-z][A-Za-z0-9]*)(\.([A-Za-z][A-Za-z0-9]*))*)(\s|,|=)/
{
{
$hashref->{$1}="";
}
}
Below regex can select each SID value from file but not able to combine with if...
(/\(CONNECT_DATA\s+=\s+\(SID\s+=\s+(\w+\d+?)(\s+)?\)/)
Sample file (tnsfile.txt)
DB1.UK, DB2.UK =
(
(ADDRESS = (PROTOCAL = TCP))
(CONNECT_DATA = (SID = db1))
)
DB1.EU, DB2.CH =
(
(ADDRESS = (PROTOCAL = TCP))
(CONNECT_DATA = (SID = db1))
)
DB3.UK =
(
(ADDRESS = (PROTOCAL = TCP))
(CONNECT_DATA = (SID = db3))
)
DB3.US =
(
(ADDRESS = (PROTOCAL = TCP))
(CONNECT_DATA = (SID = db3))
)
DB4.UK.US, DB4.US =
(
(ADDRESS = (PROTOCAL = TCP))
(CONNECT_DATA = (SID = db4))
)
Expected $hashref value:
DB1.UK
DB3.UK
DB4.UK.US
Are you caching your database handles? It sounds like you are.
If so, you just need to create a new hash that relates SID to database handles. Then you only optionally create a new handle if that SID hasn't already been loaded.
In psuedocode:
my %dbh_by_sid;
while (<DATA>) {
my $sid = ...;
my $dbh = $dbh_by_sid{$sid} ||= DBI->connect(...)
or die "DB connect failed: $DBI::errstr";
# ...
}
This way if that particular SID has already been connected to, it will reuse the same handle.
This is far from a refined solution, and it breaks if the format of your tns file changes dramatically, but you could try something like this:
use strict;
my (%tns, %sid, $tns);
open IN, 'tnsfile.txt' or die;
while (<IN>) {
if (/^([\w.]+)/) {
($tns) = $1;
}
if (/SID *= *([\w.]+)/) {
$tns{$tns} = $1 unless ($sid{$1}++)
}
}
close IN;
print join "\n", keys %tns;