Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

I do not see what does this have to do with "compatibility with WinSCP".

Anyway, Batch file is a script of cmd.exe, the same way yourscript.txt is a script of WinSCP. So if Greenshot can run WinSCP with a script, then it for sure can run even a batch file (via cmd.exe).

So instead of making Greenshot run
winscp.com /script=C:\path\to\winscpscript.txt /parameter // """{0}"""

make it run
cmd.exe /c C:\path\to\thebatch.bat """{0}"""

And the thebatch.bat would be something like I've shown above.
martin

Re: SFTP file upload to Web Server and automatically copy it’s URL to clipboard

So create the batch file. Make it call both winscp and clip, as I have shown above (you will need to use absolute path to winscp.com, the same way the Greenshot example does. And make Greenshot call the batch file. Either it can take batch file path directly as a "Command". And if not, it should be able to take cmd.exe as the Command and /c C:\path\the_batch_file.bat as its Argument.
adroman

Re: SFTP file upload to Web Server and automatically copy it’s URL to clipboard

OK, thank you very much Sir for this valuable pointer. Please let's go a little bit further 😊
Actually, what I'm trying to accomplish is to efficiently use WinSCP with Greenshot (most popular screenshot software).
There's a Greenshot manual https://getgreenshot.org/2013/11/07/how-to-upload-screenshots-to-a-web-server-via-ftp-scp-or-sftp/ how to securely upload a screenshot to Web Server. Works fine but no automatic insertion to clipboard. Their example doesn't use a “bat”-file, but maybe it can be used..
Of course, I also posted same question to Greenshot support forum but no response yet😬
Do you have any idea how to insert an URL in that scenario or it's not possible? 😊
Or maybe you know any other screenshot software where it can be done easier? 😵
martin

Re: SFTP file upload to Web Server and automatically copy it’s URL to clipboard

WinSCP scripting cannot generate an HTTP URL, nor can it copy anything to the clipboard.
But after WinSCP script finishes, you can use some other tool to do that.
Assuming your script runs from a Windows batch file, which takes the filename as a parameter, you can use Windows clip tool to do that:
winscp.com /command=yourscript.txt /parameter %1
echo https://example.com/%1| clip
adroman

SFTP file upload to Web Server and automatically copy it’s URL to clipboard

Dear Friends, I love WinSCP and I have a question for you.
I want to be able to automatically upload image file to Apache Web Server with secure SFTP protocol and automatically copy it’s URL right to the clipboard.
I have an Apache Web Server with address for example: https://example.com
I’m able to upload a file with WinSCP SFTP script to the Web Server root folder but could you please help me with automatic insertion of it’s URL to the clipboard.
For example, I want my clipboard to keep this URL: https://example.com/filename.jpg
Here’s my SFTP upload script for a single file:
# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect to server (change this to match your connection settings)
open sftp://myuser:mypassword@example.com
# Apache web-server directory
cd "/C:/xampp/htdocs"
# Upload the file to current working directory
put %1%
# Disconnect
close
# Exit WinSCP
Exit