I created a test file on my D drive. My goal is to upload it to my website from a VBA script in Excel. When I run the .bat file it hangs during the put. What am I doing wrong? I commented out the / line because that was giving me an error.
Reply when running upload.bat from command prompt
D:\>upload.bat
D:\>ftp -i -s:d:\script.dat domain.com
Connected to domain.com.
220 *** FTP Server Ready
200 UTF8 set to on
User (domain.com:(none)):
331 Password required for username
230 User username logged in
ftp> put d:\test.txt
200 PORT command successful
425 Unable to build data connection: Connection timed out
ftp> quit
221 Goodbye.
enter code here
Sub ftp()
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("d:\script.dat", True)
a.writeline "username" 'username
a.writeline "password" 'password
'a.writeline "\" 'directory on FTP site
a.writeline "put d:\test.txt" 'file to be uploaded
a.writeline "quit"
a.Close
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("d:\upload.bat", True)
a.writeline "ftp -i -s:d:\script.dat domain.com" 'the ftp site
a.Close
dRetVal = Shell("d:\upload.bat", 0) 'upload the file
Application.ScreenUpdating = True
End Sub
200 PORT command successful
425 Unable to build data connection: Connection timed out
This happens usually if your are behind some firewall or device doing NAT (i.e. typical SoHo router). FTP requires a separat data connection and in active mode (as you use here) the server tries to connect to the client - which fill fail in the given scenarios either with a connection reset or with a timeout (as in your case).
You'd better use passive mode where the client will try to connect to the server for the data connections instead. Unfortunately, the builtin command line client in Windows does not seem to support passive mode so you would need to use a different client.
Related
I am trying to connect to a secure FTP server created based on this link. I have not followed step 8 in the link. I am able to establish the connection and also change and print directories but am unable to create new directories. I am also unable to fetch files list.
Here is my code snippet:
import ssl
from ftplib import FTP_TLS
import sys
import os
import os.path
def connect():
ftp = FTP_TLS()
ftp.debugging = 2
ftp.connect('ipaddress', 21)
ftp.set_pasv(False)
ftp.login('user', 'passwd')
return ftp
ftps = connect()
destdir = "/"
try:
resp = ftps.pwd()
ftps.cwd(destdir)
except Exception:
ftps.mkd(destdir)
print(resp)
root = 'C:\\Users\\****\\****\\Logs' # local dir
for (dir, _, files) in os.walk(root):
newdir = destdir+dir[len(root):len(dir)].replace("\\", "/")
print(newdir)
try:
ftps.cwd(newdir)
except Exception:
ftps.mkd(newdir)
I am using python 3.7.3 and the corresponding ftplib. I would be happy to provide any other details required.
PS: I am able to connect with Filezilla and create directories.
This is the error after running.
I am able to create the directories successfully once I change the dir to /logs. I am getting an error "ftplib.error_perm: 500 Illegal PORT command." whenever I send cmd like retrlines or storbinary
, I get this error
I have searched about this and people have asked to set it to pasv mode. When I do that, I get this error. FYI, I have enabled pasv mode in the config file
I tried changing the port number to a number between pasv ports enabled in the config file (between 30000-31000). It does not connect also in this case. Error returned "ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it"
I am working the first time with an FTP server or for that matter any server communications, so my problems might seem trivial. I am sorry for your trouble.
Thanks.
I was able to configure mbsync and mu4e in order to use my gmail account (so far everything works fine). I am now in the process of using mu4e-context to control multiple accounts.
I cannot retrieve emails from my openmailbox account whereas I receive this error
Reading configuration file .mbsyncrc
Channel ombx
Opening master ombx-remote...
Resolving imap.ombx.io... ok
Connecting to imap.ombx.io (*.*.10*.16*:*9*)...
Opening slave ombx-local...
Connection is now encrypted
Logging in...
IMAP command 'LOGIN <user> <pass>' returned an error: NO [AUTHENTICATIONFAILED] Authentication failed.
In other posts I've seen people suggesting AuthMechs Login or PLAIN but mbsync doesn't recognizes the command. Here is my .mbsyncrc file
IMAPAccount openmailbox
Host imap.ombx.io
User user#openmailbox.org
UseIMAPS yes
# AuthMechs LOGIN
RequireSSl yes
PassCmd "echo ${PASSWORD:-$(gpg2 --no-tty -qd ~/.authinfo.gpg | sed -n 's,^machine imap.ombx.io .*password \\([^ ]*\\).*,\\1,p')}"
IMAPStore ombx-remote
Account openmailbox
MaildirStore ombx-local
Path ~/Mail/user#openmailbox.org/
Inbox ~/Mail/user#openmailbox.org/Inbox/
Channel ombx
Master :ombx-remote:
Slave :ombx-local:
# Exclude everything under the internal [Gmail] folder, except the interesting folders
Patterns *
Create Slave
Expunge Both
Sync All
SyncState *
I am using Linux Mint and my isync is version 1.1.2
Thanks in advance for any help
EDIT: I have run a debug option and I have upgraded isync to version 1.2.1
This is what the debug returned:
Reading configuration file .mbsyncrc
Channel ombx
Opening master store ombx-remote...
Resolving imap.ombx.io... ok
Connecting to imap.ombx.io (*.*.10*.16*:*9*)...
Opening slave store ombx-local...
pattern '*' (effective '*'): Path, no INBOX
got mailbox list from slave:
Connection is now encrypted
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] Openmailbox is ready to
handle your requests.
Logging in...
Authenticating with SASL mechanism PLAIN...
>>> 1 AUTHENTICATE PLAIN <authdata>
1 NO [AUTHENTICATIONFAILED] Authentication failed.
IMAP command 'AUTHENTICATE PLAIN <authdata>' returned an error: NO [AUTHENTICATIONFAILED] Authentication failed.
My .msyncrc file now contains these options instead
SSLType IMAPS
SSLVersions TLSv1.2
AuthMechs PLAIN
At the end, the solution was to use the correct password. Since openmailbox uses an application password for third-party e-mail clients I was using the wrong (original) password instead of the application password.
I am connecting to a server via a proxy that requires a client certificate to authenticate. I can easily launch a browser from my script, utilizing an ssh tunnel already established in a browser. When I attempt to open a connection using Microsoft.XMLHTTP, I receive an error
Security certificate required to access this resource is invalid.
I am looking for one of two solutions:
utilize a session that is already (manually) established in a browser
send the client certificate (and PIN) via the script.
The logic that I'm currently using for this function is very simple:
Dim xHttp: Set xHttp = CreateObject("Microsoft.XMLHTTP")
Dim bStrm: Set bStrm = CreateObject("Adodb.Stream")
xHttp.Open "GET", "https://localhost:63619/ap_detail.xml?id=3502", False
xHttp.Send
With bStrm
.Type = 1 '//binary
.Open
.Write xHttp.responseBody
.SaveToFile "C:\xml\3502.xml", 2 '//overwrite
End With
I'm using the Debian image for the BBB from here: Debian (BeagleBone Black - 2GB eMMC) 2014-05-14
This image has the Cloud9 IDE built-in. It works quite nicely for my purposes, but I can't figure out how to add a password. Anyone on the network can go to 11.22.33.44:3000 (not the actual IP address) and the IDE will automatically log them in as "John Doe" (No password requested).
Is there a way to request a user name and password when logging into Cloud9? I'm ok if the browser saves the password, but it should ask at least once.
I just found out the solution.
To set a default username and password:
Open the file /opt/cloud9/build/standalonebuild/configs/standalone.js.
Locate the following code block. (Should be at the top of the file)
if (!optimist.local) {
optimist
.boolean("t")
.describe("t", "Start in test mode")
.describe("k", "Kill tmux server in test mode")
.default("b", false)
.describe("b", "Start the bridge server - to receive commands from the cli")
.default("w", config.workspaceDir)
.describe("w", "Workspace directory")
.alias("p", "port")
.default("port", process.env.PORT || config.port)
.describe("port", "Port")
.alias("d", "debug")
.default("debug", false)
.describe("debug", "Turn debugging on")
.alias("l", "listen")
.default("listen", process.env.IP || config.host)
.describe("listen", "IP address of the server")
.boolean("help")
.describe("workspacetype")
.alias("ws", "workspacetype")
.describe("readonly", "Run in read only mode")
.alias("ro", "readonly")
.describe("packed", "Whether to use the packed version.")
.boolean("packed")
.default("packed", config.packed)
.alias("a", "auth")
.describe("auth", "Basic Auth username:password")
.default("auth", ":")
.describe("collab", "Whether to enable collab.")
.default("collab", config.collab)
// #lennartcl this should be moved
.describe("lb.fileserver", "LogicBlox file server Url")
.default("lb.fileserver", config.logicblox && config.logicblox.fileServerURL);
}
At the line .default("auth", ":"), type in the username and password you'd like to use in the format of username:password, e.g. .default("auth", "user:pass")
You should be all set! Try accessing 11.22.33.44:3000, and there should be a pop-up prompting for username and password.
On a side note, if you wish to change the profile name (the default "John Doe"):
Open the file /opt/cloud9/build/standalonebuild/settings/standalone.js.
Locate the following code block.
user: {
uid: 1,
name: "johndoe",
fullname: "John Doe",
email: "johndoe#example.org",
pubkey: null
},
Change the the value of fullname to the username you want.
Reboot BeagleBone Black and go to 11.22.33.44:3000, and you shall see updated profile name on your Cloud9 IDE.
When starting Cloud9 from the command line (at least with the latest version) you can use the:
-a user:pass
where "user" is the user name it will permit and "pass" is the password for that user. It uses basic web authentication.
Other parameters for Cloud9 are:
-l [ip addresses to accept] Use 0.0.0.0 to accept all IP addresses.
-w path/to/project/to/edit
-p port on which to operate
As for the particular script/service that is used to start Cloud9 in which to tweak the startup parameters, I'm not sure. You might try this information for where to start looking:
https://dcinglis.wordpress.com/2014/09/08/running-a-startup-script-on-a-beaglebone-black/
I'm trting to send a simple mail script in PHP. It doesn't work and I have no error in mail log or error log.
Here's my php.ini config
SMTP = relais.videotron.ca
smtp_port = 25
sendmail_from = xxxx#xxxx.com (Of cours it's my ISP email there :D)
sendmail_path = /usr/sbin/sendmail -i -t
and my simple mail() test
mail("xxxx#xxxx.com","test","test");
Nothing's work. What could it be?
The built-in PHP mail command doesn't allow you to authenticate to an SMTP server. Your ISP SMTP server requires authentication and so is refusing the connection.
The info provided by your ISP confirms this;
SMTP server is accessible from an external network by using clear text
authentication using your code "VL" or alias for your mail Example:
customer#videotron.ca
Your options are either use an SMTP server that allows anonymous connections or (as Eamorr says) use a mailer class.
I use SwiftMailer:
require_once('../lib/swiftMailer/lib/swift_required.php');
...
function sendEmail(){
//Sendmail
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
$body="Dear $fname,\n\nYour job application was successful. \n\nYours,\n\nEamorr\n\n\n\n\n\n\n";
//Create a message
$message = Swift_Message::newInstance('Subject goes here')
->setFrom(array($email => "no-reply#yourdomain.com"))
->setTo(array($email => "$fname $lname"))
->setBody($body);
//Send the message
$result = $mailer->send($message);
}
You can send both plaintext and html email with ease.