PHP Classes

File: fwphp/glomodul/mkd/01/001_instalac/001_vbox/ftp.txt

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/mkd/01/001_instalac/001_vbox/ftp.txt   Download  
File: fwphp/glomodul/mkd/01/001_instalac/001_vbox/ftp.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: Update of fwphp/glomodul/mkd/01/001_instalac/001_vbox/ftp.txt
Date: 1 year ago
Size: 7,966 bytes


Class file image Download
# WinSCP ## 1\. Access Linux share dir from Windows with WinSCP FTP How we can see RHEL type linux 64 bit share in Windows 10 64 bit Network folder ? I can in Linux file explorer ctrl+c, v files on win10 to/from Linux. With WinSCP FTP I can sync website tree. ### WinSCP FTP website tree synchronization step 1 chown -R someuser:somegroup /your/folder/here/* (Recursive mode only works on directories, not files.) This will apply chown to all files and all subdirectories and sub-subdirectories of the specified folder. Use with care. #### sudo chown -R oracle:oracle /opt/lampp/htdocs/fwphp/ On Debian Linux : var/www/html/fwphp #### sudo chmod 755 /opt/lampp/htdocs/fwphp -R ### WinSCP FTP website tree synchronization step 2 #### WinSCP FTP -> "New session" icon -> button "Edit" -> button "Advanced" #### assign SFTP value : /usr/libexec/openssh/sftp-server #### assign Shell value : sudo su - > **/opt/lampp/htdocs** /u01/userhome/oracle > To create or delete file you need have a write permissions to the directory; > To change file or directory permissions you need to be its owner; > To change file modification time you need to be its owner (note that by default WinSCP updates file modification time when uploading). ## 2\. Synchronization using PHP interpreter See 1. Grab Windows binary PHP zip package 2. extract php.exe and php7ts.dll files out of it These two binaries alone support most (if not all) features you need. No installing or registration is required. ```php <?php // call it so : php.exe example.php // system(" /script=example.txt", $exitcode); if ($exitcode == 0) { echo "success\n"; } else // handle an error { echo "error\n"; } ``` ## 3\. Automate file transfers (or synchronization) to FTP server or SFTP server In example below, WinSCP connects to server with **account user**, downloads file and closes the session. Then it connects to the same server with the **account user2** and uploads the file back. ``` # file example.txt # Connect open s -hostkey="ssh-rsa 2048 xxxxxxxxxxx...=" # Change to remote directory cd /home/user # Download file to local directory d:\ get examplefile.txt d:\ # Disconnect close # # Connect as a different user open s # Change to remote directory cd /home/user2 # Upload file to current working directory put -latest d:\examplefile.txt /home/user2 # or put -latest \toupload\* /home/user2/some_dir # or synchronize local|remote|both [ <local directory> [ <remote directory> ] ] # # Disconnect close # # Exit WinSCP exit ``` To execute script file : ** /ini=nul /script=example.txt** ## synchronize synchronizes directories **synchronize local|remote|both [ \<local directory> [ \<remote directory> ] ] ** local = changes from remote directory are applied to local directory. When the first parameter is **remote = changes from local directory are applied to the remote directory**. When the first parameter is both, both local and remote directories can be modified. When directories are not specified, current working directories are synchronized.Note: **Overwrite confirmations are always off for the command**. | Switch | Description |:-------------|:-------------| -preview | Preview changes only, do not synchronize. Transfer settings switches -permissions, -nopermissions, -speed, -transfer and -resumesupport have no effect. -nopermissions | **Keep default permissions**. -**permissions**=\<mode> | Set permissions (SFTP and SCP protocols only). -**filemask**=\<mask> | \<mask>[;\<mask2>...] Sets file mask. -transfer=\<mode> binary\|ascii\|automatic | Transfer mode: binary, ascii (text), automatic (by extension). -delete | Delete obsolete files. Ignored for both mode. -mirror | **Mirror mode (synchronize also older files)**. Ignored for both mode. -speed=\<kbps> | Limit transfer speed (in KB/s). -resumesupport= \<state> on\|off\|\<threshold> | Configures automatic resume/transfer to temporary filename. -rawtransfersettings setting1=value1 setting2=value2 ? | Allows configuring any transfer settings using raw format as in an INI file. E.g. to enable preserving of directory timestamps, use -rawtransfersettings PreserveTimeDirs=1. The switch should come only after other parameters. -criteria=\<criteria> | Comparison criteria. Possible values are time, size, either and none. Ignored for both mode. -preservetime | Preserve timestamp. **Enforced by default unless -criteria is size or none**. -nopreservetime | Do not preserve timestamp. Ignored unless -criteria is size or none. Effective options: reconnecttime, failonnomatch <br /><br /><br /> ## 4\. Basics 1. for Windows, open source free , main function is file transfer between a local and a remote computer. Based on source code of popular SSH client PuTTY, also share site settings with it. See 1. import sites from PuTTY 2. If WinSCP?s limited ability to execute remote commands does not meet your needs, you can let WinSCP open a shell session in a PuTTY client 3. To open current session also in PuTTY, go to Commands > Open in PuTTY 4. using KiTTY, instead of PuTTY 5. using OpenSSH, instead of PuTTY. Windows 10 includes Microsoft build of OpenSSH (Win32-OpenSSH) including the ssh.exe. 6. WSL using OpenSSH in Windows Subsystem for Linux, instead of PuTTY. 2. scripting and basic file manager functionality 3. SFTP client (uses secure SFTP protocol to transfer files securely to and from a remote computer). Unlike SCP, for connection with an SFTP server you do not need access to shell 4. FTP client 5. WebDAV client is extension of HTTP (using TLS/SSL) that allow users collaboration in editing/managing documents and files stored on web servers 6. S3 client see - web service offered by Amazon Web Services (AWS). Provides cloud storage through web services interfaces (REST, SOAP, and BitTorrent). WinSCP uses the REST interface to interact with S3. 7. SCP client - older protocol but almost universally supported on Unix-like platforms as part of an SSH protocol suite. It is rarely supported on other platforms. SCP is a descendant of the ancient rcp You can open additional sessions using Session > New Session or the corresponding toolbar button or keyboard shortcut. The Login dialog will show. Workspace consists of set of sites you are connected to. You can change several properties of remote files, including permissions (**chmod**) and ownership (**chown, chgrp**). You can change properties of one file only, set of files or even recursively for all files in selected directories. To change properties, select files and directories and go to File(s) > Properties. If the server does not provide some of the file attributes in directory listing, they will be requested. Properties dialog will appear then. You can also use remote file context menu or click respective toolbar button. Commands for selecting files are available from Mark menu. To move remote files, select them in file panel and then go to File(s) > Move to. You can also drag selected files to a different directory in file panel listing or directory tree. To duplicate remote files, select them in file panel and then go to File(s) > Duplicate. Edit/open remote file using editor or associated application on local machine. Once you change the file, WinSCP **uploads it back**. If your SSH server allows changing your account password, go to Session > Change Password to request that.