Upload file through vba and WinSCP.com - vba

I don't know what is happeining since it's just flashing by the screen. But I have this code in vba.
Shell "H:\Dokument\Avvikelser\WinSCP.com /script=H:\Dokument\Avvikelser\script.txt"
In script.txt i have:
open ftpes://USERNAME:PASSWORD#ftp.SERVER.nu
put H:\Dokument\Avvikelser\lista.txt /Avvikelser/lista.txt
close
As I have understood it I need ftpes to make it passive?
I can't even start WinSCP from cmd prompt
I need to use a cmd style solution as I can't install software on the computer.
The file is not uploaded when the script ends.

WinSCP.COM is only an console interface program for WinSCP.EXE, you need to have both in the same directory.
See https://winscp.net/eng/docs/executables

Related

Labview Vi's exe File not working via Python script

I made an exe file of labview project. The vi has a loop for a limited time and vi closes as the loop ends. When I open the exe file by double clicking, the vi opens and runs properly. BUT, if i try to run the exe file using Python script as below, the vi opens and stops at once and loop is not completed.
I have tried multiple python commands to run it, but nothing works. Hope someone knows the solution.
This is the code
import sys
import os
os.system("C:\\Users\\sjaved\\Desktop\\Pwm_MPC5748G_MT\\BSWs\\MCAL\\Pwm_MPC5748G\\targetTest\\NIPXI\\builds\\NI_Opponent\\Host\\Host.exe")
Some older versions of LabVIEW required the "Run when opened" option to be set in your top level VI's Execution preferences in order to auto-run when the app is executed. I tested this with a LabVIEW 2017 exe and python and the VI ran as expected (even without the "Run when opened" property set).

CMD window Close automatically after Jenkins build is over

I trying to run Selenium grid and node using Jenkins but the CMD windows always closes after executing the steps
i am running the below code in Jenkins Window Batch Command
cd "C:\TapsiumACSS\Grid3.9"
start Hub.bat
I need the CMD window to be opened
You can create a shortcut of the bat file and under properties in the target section you have to add &PAUSE
This will pause the command prompt until an user input is done.
Just a opinion, Not a good idea to use Jenkins and ask the user to do something as that defeats the whole automation aspect... Instead copy the selenium results into a html or text file which can be viewed later :)
P.S. you will have to refer to this bat file location in Jenkins i.e. the shortcut location
Hope it helps :)

Using WinSCP script for SFTP access from SSIS

I am new to WinSCP and am attempting to create a script file that will eventually be used with SSIS to download files from an SFTP site. A lot of the literature WinSCP includes explains the file downloading or uploading portions. For the time being, I just want to create a script to test the connection first and will build from there.
So far I saved the connection in WinSCP and have the following. The below code does not seem to function at all and I am not sure where else to go as I am still reading about the scripting for WinSCP. Is there a way or can someone point me in a direction to see if I am in fact connecting via through the script?
option batch on
option confirm off
open username#address
exit
Not sure what SSIS is (sorry) but I can tell you how I'd set it up from a windows batch file if that helps:
If you are open to using a different software, consider using cygwin. It mimics a linux shell so linux users on windows have a lot of linux utilities handy. That being said, there are some commands which can run on windows straight from command prompt (and thus batchable). What you'd need to do:
1) install cygwin
2) Create a "passwordless" login (using ssh-rsa authentication). To do this start your cygwin terminal and use the commands "ssh-keygen" and "ssh-copy-id" (more on that later)
3) Now you can run "sftp" from the DOS command prompt (does not require cygwin terminal) and sftp to your account. No password required because of step 2).
A few follow up info:
What can run from dos command prompt and what must be run from cygwin terminal?
If you go to the "bin" directory of cygwin (for me it's in c:\cygwin\bin) you can see all the cygwin utilities. Anything with "exe" extension can be run from dos command prompt. If no "exe" extension, must start cygwin terminal first
How to set up ssh-rsa authentication?
You can pretty much google "ssh login without password" and pull up a lot of results. This is common for setting up login from one linux system to another. You would be using the same steps using cygwin on windows. My instructions are here:
http://geekswing.com/geek/unix/how-to-ssh-login-without-a-password-using-ssh-keygen-quick-tutorial/
Storing session settings in WinSCP GUI and trying to access them from WinSCP script running in SSIS is generally a bad idea. I believe there's no example or guide on WinSCP site that would suggest doing that.
WinSCP stores its configuration in registry in HKEY_CURRENT_USER hive. The SSIS typically runs under a dedicated system account, that have its own HKEY_CURRENT_USER hive, and won't see the GUI configuration.
For details see WinSCP FAQ about your problem:
https://winscp.net/eng/docs/faq_scheduler
The best you can do is isolate your your script from configuration by using the session URL with the open command, instead of the stored site name.
See also https://winscp.net/eng/docs/scripting#configuration
Your actual problem can be completely different though. But that's hard to guess as you have not shared any details, such as error message, log file, etc.

File.execute() is not executing my script. How to debug this issue?

I'm writing a script for Illustrator CS6 in ExtendScript. At the end of my script, I want to spawn a task (a second script, in Ruby) using File.execute(). However, it's not working. And I'm at a loss as how to debug the problem -- how can I figure out why this isn't working?
Here's the end of my ExtendScript file:
// Do a bunch of other work, then:
var rubyFile = new File(scriptFolder + 'BuildHtmlWalkthrough.rb');
alert(rubyFile.exists);
var result = rubyFile.execute();
alert(result);
Both rubyFile.exists and result are always true, indicating that the script launched OK. But the script does not appear to run, at all. I've tried the following diagnostics:
The Ruby script does successfully run from the command line. The script's permissions are -rwxr-xr-x
I added a call to system("touch /blah/blah/blah") as the very first line of the Ruby script. The file does not get touched.
I thought maybe the ExtendScript process was terminating before the Ruby script could run, so I added a long for loop after rubyFile.execute(). Spinning for > 30 seconds did not help.
What can I do to debug, or solve, this problem?
I'm on MacOS X v10.9.1. And for reference, this is the documentation for File.execute():
File.execute (): Boolean
Core JavaScript Classes
Executes or opens
this file using the appropriate application, as if it had been
double-clicked in a file browser. You can use this method to run
scripts, launch applications, and so on. Returns true immediately if
the application launch was successful.
It's probably doing the "opens this file using the appropriate application" instead of executing, and returns true because the file successfully opens (or is already open in its associated app). If I have a python script and do
f= new File("~/Documents/misc_scripts/getpixelrgb.py");
f.execute();
, it opens it in my script editor, even if the file's execute flags are set.
I'm on OSX, btw
In After Effects, there is system.callSystem() to execute command line commands, but I'm afraid that is absent in Illustrator (I'm assuming you're doing this for Illustrator because of the tag). Are you on OSX or Windows? There are ways around this, by making an executable .app (OSX) or .exe (Win) and calling that with execute(). If I were doing this, I'm on OSX and I'd make an AppleScript app that does 'do shell script' to make the ruby system call. On Windows, it's different. One solution you might like if you're on windows: ocra, which is ruby-specific (http://ocra.rubyforge.org/). It may be possible to run a .bat file on Windows that calls the ruby script, but I'm not sure.
[edit!]
Terribly sorry for the extraneous Windows info (for someone else, I guess). Just saw your note about being on OSX. So you might want to use the AppleScript solution.
[edit again]
So, if my ruby script ("test.rb") is:
#!/usr/bin/env ruby
print "Hello"
and my AppleScript is:
do shell script "cd /testing_folder/; ruby test.rb"
Then I get "Hello" returned in AppleScript, but ExtendScript will just return true.

Using applescript to run terminal and passing a argument to compile

I am new to applescripts and i want to automate a little bit of my app.So here is the thing
1) I am using textwrangler as an editor
2) After writing code and saving it i want to compile the file by opening terminal from applescript.I already installed llvm compiler.
3) As textwrangler provides me the a menu in meubar to open script editor so after opening it i am using "tell application "Terminal" to activate" it opens terminal
4) i want " gcc myfilename.c " to be passed as argument from applescript so that as soon terminal opens this string should be passed as argument and executable is generated
Can i Do that through scripts? Please help.
Give this a try:
tell application "Terminal" to do script "gcc myfilename.c"
Running this without the Activate line you mentioned will still open Terminal if it isn't already open, but it won't bring it to the front. For that, Just turn the whole thing into a tell block and put the Activate back in there so it becomes:
tell application "Terminal"
activate
do script "gcc myfilename.c"
end tell