Differences

This shows you the differences between the selected revisions of the page.

faq_script_vs_gui 2023-01-20 faq_script_vs_gui 2024-09-18 (current)
Line 8: Line 8:
See another FAQ: [[faq_scheduler|*]] (Although it covers a different topic, its recommendations are valid for this case as well). See another FAQ: [[faq_scheduler|*]] (Although it covers a different topic, its recommendations are valid for this case as well).
-==== Configuration ===+==== [[configuration]] Configuration ===
You have your [[session_configuration|session configured]] differently in the script and in the %%GUI%%. You have your [[session_configuration|session configured]] differently in the script and in the %%GUI%%.
-  * Use a [[ui_generateurl|Generate Session URL/Code]] command to avoid common mistakes in manually typed URL's or code; and to make sure all the settings from your GUI configuration is used in the script. \\ A common problem is [[session_url#special|special characters]] in some part of the [[session_url|session URL]] (typically a password or a username).+  * Use a [[ui_generateurl|Generate Session URL/Code]] command to avoid common mistakes in manually typed URL's or code; and to make sure all the settings from your GUI configuration is used in the script. \\ A common problem is [[session_url#special|special characters]] in some part of the [[session_url|session URL]] (typically a password or a username). \\ Further, some characters have special meaning in string literals in programming languages. If your password (or other credential) contains such special character, it needs to be escaped using the rules of the language. Notably in PowerShell, a dollar sign has special meaning in double-quoted string. Code generated by WinSCP escapes these too.
  * Passphrase to an SSH private key is not a password, you need to specify it using ''[[scriptcommand_open|-passphrase]]'' switch, not in a password part of the session %%URL%%.   * Passphrase to an SSH private key is not a password, you need to specify it using ''[[scriptcommand_open|-passphrase]]'' switch, not in a password part of the session %%URL%%.
  * With [[webdav|WebDAV]] and [[s3|S3]] protocols, it is possible that [[faq_root_path|you do not have an access to the root folder (bucket list in S3)]].   * With [[webdav|WebDAV]] and [[s3|S3]] protocols, it is possible that [[faq_root_path|you do not have an access to the root folder (bucket list in S3)]].
Line 22: Line 22:
  * Remote paths are case sensitive. So ''Data'' is not the same as ''data''.   * Remote paths are case sensitive. So ''Data'' is not the same as ''data''.
-===== Logging =====+==== [[inputs]] Source and Destination Inputs ==== 
 + 
 +Commands in scripting (like [[scriptcommand_put|''put'']] and [[scriptcommand_get|''get'']]) and some methods in .NET assembly (like [[library_session_getfiles|''Session.GetFiles'']] and [[library_session_putfiles|''Session.PutFiles'']]) do not take mere paths as inputs. The source input is expected to be a path terminated by a slash (a backslash when uploading) and followed by a [[file_mask|file mask]]. Similarly the destination input is expected to be a path also terminated by a slash (a backslash when downloading) followed by an optional [[operation_mask|operation mask]]. As a simple example, a command to upload all files in scripting should be like: 
 +<code winscp> 
 +put C:\source\path\* /destination/path/ 
 +</code> 
 +Similarly in .NET assembly: 
 +<code csharp> 
 +$session.PutFiles("C:\source\path\*", "/destination/path/").Check() 
 +</code> 
 +The trailing ''\*'' in the source path and the ''/'' in the destination path both matter. Read documentation of respective scripting commands or .NET assembly methods for details. In .NET assembly, in many cases, it's easier to use more specific methods like [[library_session_putfiletodirectory|''Session.PutFileToDirectory'']], [[library_session_putfilestodirectory|''Session.PutFilesToDirectory'']],[[library_session_getfiletodirectory|''Session.GetFileToDirectory'']] or [[library_session_getfilestodirectory|''Session.GetFilesToDirectory'']], as they do not have that strict interpretation of the inputs. 
 + 
 +===== [[logging]] Logging =====
You can also enable a [[logging|session logging]] both in the %%GUI%% (on //[[ui_pref_logging|Logging page]]// of Preferences dialog) and the script (using a command-line parameter ''[[commandline#logging|/log]]'') and compare the logs to find out what is different. Use a command-line parameter ''[[commandline#logging|/loglevel=*]]'' to enable a password logging and check if a correct password is used. You can also enable a [[logging|session logging]] both in the %%GUI%% (on //[[ui_pref_logging|Logging page]]// of Preferences dialog) and the script (using a command-line parameter ''[[commandline#logging|/log]]'') and compare the logs to find out what is different. Use a command-line parameter ''[[commandline#logging|/loglevel=*]]'' to enable a password logging and check if a correct password is used.

Last modified: by martin