M
M
mike89klein2022-03-05 18:50:25
css
mike89klein, 2022-03-05 18:50:25

What is the correct way to pass the WinSCP command?

Hello. I want to automate the work of uploading files using WinSCP. Wrote a little code:

import subprocess

opencom='"open scp://[email protected]/'
hostkey='-hostkey=""ssh-XXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX""'
privatekey='-privatekey=""C:\Users\User\.ssh\key.ppk""' 
passphrase='-passphrase=""key"""'

args = ["C:\\Program Files (x86)\\WinSCP\\WinSCP.com", "/ini=nul", "/command", opencom, hostkey, privatkey, passphrase]

subprocess.Popen(args)


But the error "Unknown command '\open'" is thrown. Tell me, please, how to deal with it?

I found options for working with WinSCP using the command:
subprocess.run(["winscp.com", "/script=" + cmdFile], shell=True)
where cmdFile is the script itself.
But this does not suit me, since I need to pass the values ​​\u200b\u200bof additional variables in the python file itself

Answer the question

In order to leave comments, you need to log in

8 answer(s)
S
Sergey Suntsev, 2016-04-27
@GreyCrew

as an option, if you are loading something, via ajax, then you can use this

$.ajax({
                beforeSend: function () {
                    preloader.fadeIn(); //функция начала загрузки
                },
                success: function(){
                    preloader.fadeOut(); // функция конца загрузки
                }
            });

M
Maxim Timofeev, 2016-04-27
@webinar

The easiest way is to simulate the download progress. First load the block with a stub and loading, for example: getbootstrap.com/components/#progress-animated
then in js after full load or when ready do display:none; for a stub. The loading progress indicator can theoretically be tied to large photos, for example. Through:

$('селектор_крупной_фотки').load(function(){
    $('селектор_индикатора').css('width','80%');
});

Climbing in the chrome developer panel, you can find a timeline where you can see which element loaded and when, from here you can find checkpoints for the indicator.
But it seems to me that it is necessary to optimize the pages of the site, so they loaded in 1-2s. Then an ordinary spinning ball is enough without showing the loading stages.

S
seriogja, 2016-04-27
@seriogja

Hello!
In my opinion, there is no point in making the preloader a percentage, since it is impossible to determine what to take as a percentage unit of a given progressbar. Number of pictures, scripts? If you do a progressbar as Sergey Suntsev suggested , then there will only be positions in the progressbar, which does not make sense (as part of the page load). If you do as Alexander Aksentiev suggested , i.e. the number of scripts is taken as 100%, then in general the progressbar will show the left number. Uploading (maybe 1000) css files, pictures, fonts will not be counted. And, if some script does not load, this does not mean that the page has not loaded.
I think the best option is to hide the content until the page is fully loaded, and show the preloader until it loads.

C
chigoe, 2016-04-29
@chigoe

Here's a good thing, there are percentages in themes: pace.js

A
Alexander Aksentiev, 2016-04-27
@Sanasol

There is no way to do this.
Especially if you use loadable modules with dependencies.
If the number of scripts is fixed, you can of course set 100% as the number of all scripts and add a callback to each script that it has loaded.
And build progress on this, but this is far from automatic, and it will come out quite gemorno.

W
wshaman, 2016-04-27
@wshaman

The only place where I met a real percentage-based loading bar of a site is a flash site.
Only for this (website on flash) ... hmm. This is bad.
In the case of loading resources in the classical way, as far as I know, there is no such adequate possibility.

I
Ivan, 2016-04-27
@c64

You can do this if you load resources with some kind of library that can do a callback on loading a single element (I remember yepnope and head.js for js and css, for pictures it probably also exists). In this case, you will have to measure manually (in advance) and put the sizes of each element into an array (for example, {logo.css: 33kb, libs.js: 11kb, img01.jpg: 123kb}). Thus, you will know in advance the volume of all information and the contribution of each element, and by loading individual parts you will receive percentage readiness.
If this is not automated, then every time the file size is changed, the array will have to be updated, in addition, such a page looks strange in the eyes of the search engine (because everything in it is loaded by JS).

D
Dr. Bacon, 2022-03-06
@mike89klein

Why do this at all when there is a paramiko library for working with ssh?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question