Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9061701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:33:10+00:00 2026-06-16T15:33:10+00:00

I am currently trying to get a FTP server up and running and I

  • 0

I am currently trying to get a FTP server up and running and I can’t even get Finder on Mac OS X to connect…

Finder Error:

There was a problem connecting to the server “192.168.1.67”.
Check the server name or IP address, and then try again. If you continue to have problems, contact your system administrator.

stdout output

python FTPtoEMAIL.py 
2013-01-01 17:16:01-0500 [-] Log opened.
2013-01-01 17:16:01-0500 [-] FTPFactory starting on 7654
2013-01-01 17:16:01-0500 [-] Starting factory <twisted.protocols.ftp.FTPFactory instance at 0x6aff80>
2013-01-01 17:16:26-0500 [FTP (ProtocolWrapper),0,192.168.1.67] Setting up avatar
2013-01-01 17:16:26-0500 [FTP (ProtocolWrapper),0,192.168.1.67] apple
2013-01-01 17:16:26-0500 [FTP (ProtocolWrapper),1,192.168.1.67] Setting up avatar
2013-01-01 17:16:26-0500 [FTP (ProtocolWrapper),1,192.168.1.67] apple
^C2013-01-01 17:16:35-0500 [-] Received SIGINT, shutting down.
2013-01-01 17:16:35-0500 [twisted.protocols.ftp.FTPFactory] (TCP Port 7654 Closed)
2013-01-01 17:16:35-0500 [twisted.protocols.ftp.FTPFactory] Stopping factory <twisted.protocols.ftp.FTPFactory instance at 0x6aff80>
2013-01-01 17:16:35-0500 [-] Main loop terminated.

Code

import sys
import EMail
from twisted.protocols.ftp import FTPFactory, FTPRealm
from twisted.cred.portal import Portal
from twisted.cred import checkers
from twisted.cred.checkers import AllowAnonymousAccess, FilePasswordDB
from twisted.internet import reactor
from twisted.python import log
from twisted.internet.defer import succeed, failure

from twisted.protocols.ftp import FTPFactory, FTPRealm, FTP, FTPShell, IFTPShell

# EMail Shell
USER = "Apple"
PASSWORD = "Orange"


class EMailtoFTPShell(object):
    """
        An abstraction of the shell commands used by the FTP protocol for
        a given user account.

        All path names must be absolute.
        """

    def __init__(path, avatar):
        print path
        print avatar

        self.root_path = path
        self.avatar = avatar

    def makeDirectory(path):
        """
            Create a directory.

            @param path: The path, as a list of segments, to create
            @type path: C{list} of C{unicode}

            @return: A Deferred which fires when the directory has been
            created, or which fails if the directory cannot be created.
            """
        print path

        path = os.path.join(self.root_path, path)

        os.mkdir(path)

        return succeed(path)

    def removeDirectory(path):
        """
            Remove a directory.

            @param path: The path, as a list of segments, to remove
            @type path: C{list} of C{unicode}

            @return: A Deferred which fires when the directory has been
            removed, or which fails if the directory cannot be removed.
            """
        print path
        path = os.path.join(self.root_path, path)

        os.rremovedir(path)

        return succeed(path)

    def removeFile(path):
        """
            Remove a file.

            @param path: The path, as a list of segments, to remove
            @type path: C{list} of C{unicode}

            @return: A Deferred which fires when the file has been
            removed, or which fails if the file cannot be removed.
            """
        print path

        path = os.path.join(self.root_path, path)

        os.remove(path)

    def rename(fromPath, toPath):
        """
            Rename a file or directory.

            @param fromPath: The current name of the path.
            @type fromPath: C{list} of C{unicode}

            @param toPath: The desired new name of the path.
            @type toPath: C{list} of C{unicode}

            @return: A Deferred which fires when the path has been
            renamed, or which fails if the path cannot be renamed.
            """
        print fromPath
        print toPath

        fromPath = os.path.join(self.root_path, fromPath)
        toPath   = os.path.join(self.root_path, toPath)

        os.rename(fromPath, toPath)

        succeed(toPath)

    def access(path):
        """
            Determine whether access to the given path is allowed.

            @param path: The path, as a list of segments

            @return: A Deferred which fires with None if access is allowed
            or which fails with a specific exception type if access is
            denied.
            """
        print path

        return succeed(None)

    def stat(path, keys=()):
        """
            Retrieve information about the given path.

            This is like list, except it will never return results about
            child paths.
            """
        print path
        print keys

        #todo

    def list(path, keys=()):
        """
            Retrieve information about the given path.

            If the path represents a non-directory, the result list should
            have only one entry with information about that non-directory.
            Otherwise, the result list should have an element for each
            child of the directory.

            @param path: The path, as a list of segments, to list
            @type path: C{list} of C{unicode}

            @param keys: A tuple of keys desired in the resulting
            dictionaries.

            @return: A Deferred which fires with a list of (name, list),
            where the name is the name of the entry as a unicode string
            and each list contains values corresponding to the requested
            keys.  The following are possible elements of keys, and the
            values which should be returned for them:

            - C{'size'}: size in bytes, as an integer (this is kinda required)

            - C{'directory'}: boolean indicating the type of this entry

            - C{'permissions'}: a bitvector (see os.stat(foo).st_mode)

            - C{'hardlinks'}: Number of hard links to this entry

            - C{'modified'}: number of seconds since the epoch since entry was
            modified

            - C{'owner'}: string indicating the user owner of this entry

            - C{'group'}: string indicating the group owner of this entry
            """
        print path
        print keys

        #todo

    def openForReading(path):
        """
            @param path: The path, as a list of segments, to open
            @type path: C{list} of C{unicode}

            @rtype: C{Deferred} which will fire with L{IReadFile}
            """
        print path

        # fetch from the email server
        metadata = EMail.parse_file(os.join(self.root_path, path))

        return fetch_from_mail_server(metadata, "READ")

    def openForWriting(path):
        """
            @param path: The path, as a list of segments, to open
            @type path: C{list} of C{unicode}

            @rtype: C{Deferred} which will fire with L{IWriteFile}
            """
        print path

        # fetch from the email server
        metadata = EMail.parse_file(os.join(self.root_path, path))

        return fetch_from_mail_server(metadata, "WRTE")

class EMailToFTPRealm(object):

    def __init__(self):
        pass

    def requestAvatar(self, avatarId, mind, *interfaces):
        for iface in interfaces:
            if iface is IFTPShell:
                if not avatarId is checkers.ANONYMOUS:
                    print "Setting up avatar"
                    print avatarId
                    avatar = EMailtoFTPShell("/Users/FTP_Server/", avatarId)
                    return IFTPShell, avatar, getattr(avatar, 'logout', lambda: None)
        raise NotImplementedError("Only IFTPShell interface is supported by this realm")


if __name__ == "__main__":

    p = Portal(EMailToFTPRealm(),
           [FilePasswordDB("pass.dat")])

    f = FTPFactory(p)

    log.startLogging(sys.stdout)
    reactor.listenTCP(7654, f)
    reactor.run()

pass.dat

apple:orange
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:33:11+00:00Added an answer on June 16, 2026 at 3:33 pm

    On the basis that twistd is working and you were able to connect to the FTP server using Finder, this looks an OS X issue rather than a Twisted one.

    The write issue is occurring because FTP connections made via Finder are read-only (as per this Apple Support article)

    Assuming you’re using the pass.dat file above, your computer’s standard login won’t work because it’s not listed in that file! You need to use a login that is specified in your pass.dat file and has access to the ftp server’s root directory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to get a Tomcat server I have running in Eclipse on
I am currently trying to get my server to create a connection with a
I'm trying to get a directory listing of files on an ftp server using
I'm currently trying to get one of my unit tests to work, but there
I'm currently trying to get g++ working, and looking at http://gcc.gnu.org/install/build.html , I can't
i currently trying to get my model loader to work and got a error
I am trying to log into a FTP server that I am only running
I'm currently trying to get CMake running for my project (on windows). I want
I'm currently trying to get the most popular productID from my MSSQL Database. This
I am currently trying to get my app to run on my iPhone 4.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.