Jump to content

Sending file to FTP server


archiebaker

Recommended Posts

Hey guys :) so i'm in the process of creating an auto muler for private use yet could do with some help.

I've currently tried:

  • Starting another client by running a batch file from a script (Doesn't work as OsBot won't allow the execution of a batch file)
  • Sending a .txt file to a ftp which I will then read from, enabling my bots to communicate with each other.

 

I'm using an FTP from a minecraft server I used to run (So I may not have permission to change everything but can still add/delete files)

 

The problem is when I try to connect to the FTP to move a file I get this error

image.png.a22f5bbd982966a0e05d0b4da1efcdd5.png

 

I've added a grant to java.policy (Still no luck)

 

grant {
    permission java.net.SocketPermission "localhost:0", "listen,resolve";
};

My current code is

		if (progress == 0) {	
			log ("Attempting to call muleaaaa");
			String ftpUrl = "ftp://%s:%s@%s/%s;type=i";
			String host = "";
			String user = "";
			String pass = "";
			String filePath = "file:/C:/Users/admin/OSBot/data/test.txt"; 
			String uploadPath = "logs/test.txt";			
			ftpUrl = String.format(ftpUrl, user, pass, host, uploadPath);
			log("Upload URL: " + ftpUrl);

			try {
			    URL url = new URL(ftpUrl);
			    URLConnection conn = url.openConnection();
			    OutputStream outputStream = conn.getOutputStream();
			    FileInputStream inputStream = new FileInputStream(filePath);

			    byte[] buffer = new byte[5];
			    int bytesRead = -1;
			    while ((bytesRead = inputStream.read(buffer)) != -1) {
			        outputStream.write(buffer, 0, bytesRead);
			    }

			    inputStream.close();
			    outputStream.close();

			   log("File uploaded");
			} catch (IOException ex) {
			    ex.printStackTrace();
			    logger.error(ex);
			}

 

As you can probably tell i'm not the most experienced in networking.

 

Was just looking if anyone else has had this error (I've tried googling)

 

If this is due to OsBot is a webserver (I'd have to look into how to do that) the next best way to set up an auto mule script?

Thankyou!

 

Edited by archiebaker
Link to comment
Share on other sites

On 25/09/2017 at 1:12 PM, archiebaker said:

I'm a complete noob at both of them. So i'll have some learning to do!

Would I still be able to use the same FTP to host the database on?

You probably won't be able to host a mySQL server on the FTP server. I agree with Night, a mySQL server is probably the best solution. You can get a basic web hosting package which will have a mySQL database and run php scripts for $2 a month at loads of places.

 

Alternatively, if you want to stick to your method with an FTP server, it might be a good idea to use a 3rd party ftp library such as apache commons http://commons.apache.org/proper/commons-net/

 

Another method I used to use was by reading a pastebin text file. I'd just get my script to check the paste every few minutes and if it contained a number and a username, it would go to that world in lummy and trade over all the supplies to the account with that username. I'd do all the trades then edit the paste to be blank again.

Edited by Diclonius
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...