<div dir="ltr">At a guess, you're using a modern FTP client that defaults to passive mode for compatibility with firewalls, and you'll need to check the docs to see how to do passive mode with Network.Client.FTP.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 5, 2021 at 7:24 AM Kees Bleijenberg <<a href="mailto:K.Bleijenberg@lijbrandt.nl">K.Bleijenberg@lijbrandt.nl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I want to upload a file with ftp using library Network.FTP.Client.<br>
The OS is Windows 64 and ghc version is 8.6.4.<br>
<br>
This is the code:<br>
<br>
import System.FilePath.Windows<br>
import Network.FTP.Client<br>
import qualified Data.ByteString as B<br>
....<br>
testFtp :: IO (Either String ())<br>
testFtp = do<br>
   let host = "copecco"  -- this is from my hosts file       <br>
       username = ****<br>
       pwd = ****<br>
       ftpDir = "registratie"<br>
       fileToSend = "globals.pas"  -- a test text file<br>
   putStrLn $ "Connect to " ++ host<br>
   withFTP host 21 $ \h ftpResponse -> do <br>
         print ftpResponse<br>
         if frStatus ftpResponse == Success <br>
         then do <br>
                  putStrLn "Connected"<br>
                  loginResp <- login h username pwd<br>
                  print loginResp<br>
                  if frStatus loginResp == Success<br>
                  then do <br>
                           putStrLn $ "Change directory to " ++ ftpDir<br>
                           cwdResp <- cwd h ftpDir<br>
                           print cwdResp<br>
                           if frStatus cwdResp == Success <br>
                           then do  <br>
                                    putStrLn "Read file from disk"<br>
                                    let ftpFn =  takeFileName fileToSend <br>
                                    fileContents <- B.readFile fileToSend <br>
                                    putStrLn $ "File size: " ++ show<br>
(B.length fileContents) ++ " bytes"<br>
                                    stor h ftpFn fileContents TI<br>
                                    return $ Right ()<br>
                           else return $ Left $ "Ftp error cwd. Code: " ++<br>
show (frCode ftpResponse)<br>
                  else return $ Left $ "Ftp error login. Code: " ++ show<br>
(frCode ftpResponse)<br>
         else return $ Left $ "Connect to host " ++ host  ++ " failed. Code:<br>
" ++ show (frCode ftpResponse)<br>
<br>
This is the response:<br>
Connect to copecco<br>
<br>
220 (vsFTPd 3.0.2)<br>
<br>
Connected<br>
<br>
230 Login successful.<br>
<br>
Change directory to registratie<br>
<br>
250 Directory successfully changed.<br>
<br>
Read file<br>
<br>
File size: 27015 bytes<br>
<br>
*** Exception: Network.Socket.connect: <socket: 444>: failed (Connection<br>
timed out (WSAETIMEDOUT))  <br>
<br>
Everything works fine until the stor commmand. <br>
When I upload the same file with another ftp client program everything works<br>
(no permission problems).<br>
<br>
What is wrong and how do I get the result codes for the stor command?<br>
<br>
Kees<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>brandon s allbery kf8nh</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a></div></div></div></div></div>