How to download files from a FTP using PhantomJS - ftp

I have a file on a FTP Server. I´m trying to download it using PhantomJS. I´ve tried using the following code:
var page = require('webpage').create();
page.open('ftp://USERNAME:PASSWORD#www.mywebsite.com/exempleFIle.xlsx');
phantom.exit();
It runs without throwing any errors, however the file is not downloaded. Is it possible to download it with PhantomJS?
My main goal is synchronizing the files in the FTP with my computer, so I can put it in my Google Drive and from there using it in my reports. I use PhantomJS to access some webpages and get some data for the same purpose. Since I´m already using PhantomJS, I thought I could do the same for the ftp server, but if there is a simpler solution that use other methods, I´m open to trying it.
Thank You

PhantomJS is a headless web-browser, it's not an FTP client, so it won't be able to help you.
My main goal is synchronizing the files in the FTP with my computer
I'd suggest using lftp.
lftp -u user,password -e 'mirror /remote/server/files/ /local/computer/files/' ftp.myserver.com
This will get files from the remote server to the local computer.

Related

Download a file from FTP via proxy with Ruby

I have an app running on Heroku, and I need to download a file from an FTP. But I need to do it using a fixed IP. I´m using www.quotaguard.com to have fixed IPs.
But I can´t get it working.
Does anyone has a Ruby example to download a file from an FTP via a proxy server (quotaguard).
Both the proxy server and the FTP require username and password.
I´ve tried everything, using Ruby. And also calling wget from system to initiate a download, but wget apparently doesn´t go via the proxy. Also checked many posts, but no success so far.
I´m using Ruby 2.4.5
Thanks for any comments.
Thank you QuotaGuard. Socksify is not maintained and really old, we gave it a try but didn´t want to spend much time on it.
We actually managed to get this working with curl. You can call it within Heroku as well.
Here´s the command in case anyone wonders.
curl -x socks5h://socksproxyurl 'ftp://theftp/some.pdf' --user "ftp_user:ftp_pass" -o some.pdf
We've seen a few customers do this before with the socksify gem.
require 'socksify'
proxy = URI(ENV['QUOTAGUARDSTATIC_URL'])
TCPSocket::socks_username = proxy.user
TCPSocket::socks_password = proxy.password
Socksify::proxy(proxy.hostname, 1080) do |soc|
# do your FTP stuff in here
end
If that doesn't do it, post the errors you're seeing and we'll help get this running for you.

What command to use to transfer file from one server to another server

I want to automate the process of transferring files between servers that is done using WinSCP. Can we automate this process through jmeter using OS process sampler. Please help me with the command to transfer files and how to connect to servers using jmeter and transfer files.
Use Jmeter Plugin jmeter-ssh-sampler for this:
And then can use SCP command to transfer file from one server to another server.
To copy a file from a local to a remote system run the following command:
Commad : scp file.txt remote_username#10.10.0.2:/remote/directory
Below is the link to the plugin:
jmeter-ssh-sampler link

How to download a file from my server using SSH (using PuTTY on Windows)

When I try downloading a file from my server onto my computer, it actually downloads the file onto the server.
(Note I am already SSH'd into my server before typing this command. I've watched tutorials on YouTube and people are using their terminal without SSHing into any particular server, however I don't think I can do this with PuTTY on Windows?)
scp -r -P2222 kwazy#mywebsite.example:/home2/kwazy/www/utrecht-connected.nl ~/Desktop/
The problem is that I am specifying the location to download the file as only ~/Desktop/
This creates a folder called Desktop in my server, instead of copying the files onto my local desktop.
I am able to use this command on Linux.
I have successfully download the folder onto my desktop:
I still need insight onto how I can do this on a Windows machine.
There's no way to initiate a file transfer back to/from local Windows from a SSH session opened in PuTTY window.
Though PuTTY supports connection-sharing.
While you still need to run a compatible file transfer client (pscp or psftp), no new login is required, it automatically (if enabled) makes use of an existing PuTTY session.
To enable the sharing see:
Sharing an SSH connection between PuTTY tools.
Even without connection-sharing, you can still use the psftp or pscp from Windows command line.
See How to use PSCP to copy file from Unix machine to Windows machine ...?
Note that the scp is OpenSSH program. It's primarily *nix program, but you can run it via Windows Subsystem for Linux or get a Windows build from Win32-OpenSSH (it is already built-in in the recent versions of Windows 10 and in Windows 11).
If you really want to download the files to a local desktop, you have to specify a target path as %USERPROFILE%\Desktop (what typically resolves to a path like C:\Users\username\Desktop).
Alternative way is to use WinSCP, a GUI SFTP/SCP client. While you browse the remote site, you can anytime open SSH terminal to the same site using Open in PuTTY command.
See Opening Session in PuTTY.
With an additional setup, you can even make PuTTY automatically navigate to the same directory you are browsing with WinSCP.
See Opening PuTTY in the same directory.
(I'm the author of WinSCP)
try this scp -r -P2222 kwazy#mywebsite.example:/home2/kwazy/www/utrecht-connected.nl /Desktop
Another easier option if you're going to be pulling files left and right is to just use an SFTP client like WinSCP. Then you're not typing out 100 characters every time you want to pull something, just drag and drop.
Just noticed /Desktop probably isn't where you're looking to download the file to. Should be something like C:\Users\you\Desktop
OpenSSH has been added to Windows as of autumn 2018, and is included in Windows 10 and Windows Server 2019.
So you can use it in command prompt or power shell like bellow.
C:\Users\Parsa>scp parsa#192.168.100.11:/etc/cassandra/cassandra.yaml F:\Temporary
parsa#192.168.100.11's password:
cassandra.yaml 100% 66KB 71.3KB/s 00:00
C:\Users\Parsa>
(I know this question is pretty old now but this can be helpful for newcomers to this question)
if you install git with git bash, you get SCP available on windows.
You can use WinSCP : https://winscp.net/eng/download.php
Or MobaXterm : https://mobaxterm.mobatek.net/download.html
It feels like FTP client. Also I don't remember setting up anything on my machine for this. It just fresh install and install SSH server (IDK if it matters though).
For MobaXterm :
If your server have a http service you can compress your directory and download the compressed file.
Compress:
tar -zcvf archive-name.tar.gz -C directory-name .
Download throught your browser:
http://the-server-ip/archive-name.tar.gz
If you don't have direct access to the server ip, do a ssh tunnel throught putty, and forward the 80 port in some local port, and you can download the file.
You can use the WinSPC program. Its access to any server is pretty easy. The program gives its guide too. I hope it's helpfull.
If you need something with GUI you can use FileZilla. it support SFTP.
It's perfectly working with ssh and you can even edit files and it will automatically upload the changes.

Confusion about FTP

I am learning web development and I'm a bit stuck with FTP. I know it's used for file transfer but how do I actually use it? I found some PHP functions to connect to the FTP server and log in but what do I log in with? How do I create a username? Is FTP something like MySQL with it's own command line? Or is it something like Apache?
I am using Ubuntu 12.04 and I have LAMP installed. I found somewhere that I need to install a program to use FTP but I found somewhere else that I need to install FTP while installing PHP. This is really confusing.
Thanks.
FTP is File Transfer Protocol. It is not a programming language. FTP is used to connect to a computer to access its file system - to upload or download files. Imagine opening a folder on firends pc from you computer. In most linux you can type in a ftp address to the location bar in whatever file browser your using and access the ftp server as if it was a local folder. You can also use specific software for that - gftp, filezilla.
A ftp daemon does not come with lamp. Please refer to https://help.ubuntu.com/12.04/serverguide/ftp-server.html for details on how to install/configure a ftp daemon on ubuntu.
What you will use ftp for is to put your .php files on a remote machine. If you are doing things on your computer only it is likely that you do not need ftp.

Access FTP via Proxy using command line

I need to be able to upload/download files to FTP via a proxy server as FTP access is blocked. All this being an automated script, I did find net2ftp.com but they don't have command line feature yet.
I have been using NCFTPGET and NCFTPPUT all this while, but on networks which have FTP blocked, I get stuck.
I have found an alternate method wget which can use proxies for downloading from FTP and HTTP as well.
Read the manual here -> http://www.gnu.org/software/wget/manual/wget.html
Update
I have moved over to cURL , its a much better refined command line tool. More details -> http://curl.haxx.se/

Resources