How to generate transfer code/script in WinSCP - sftp

I have the below command I started writing to copy a file from a local box to the remote directory. I am very new to this and confused by the documentation somewhat. Can I use the "Your Command 1 and 2" params at the end to do like "c:\somefile.txt" "\in\"?
I want to do this without PowerShell, or script. Just raw command line and no additional files to import in command line args. My goal is to set up a Windows Task Scheduler job and has it run this single command.
C:\Program Files (x86)\WinSCP\WinSCP.exe /log="C:\writable\path\to\log\WinSCP.log" /ini=nul /command "open sftp://myusername#myftpsite.com/ -hostkey=""ssh-rsa 2048 wbb2bQRmDJqkaLbuYKsnGdxQ40mIIedeXChRsAYC3ig="" -privatekey=""C:\Users\my.user\Documents\SSHPrivateKey.ppk""" "Your command 1" "Your command 2" "exit"
I see some examples here… https://winscp.net/eng/docs/commandline#scripting
Can't find auto-generate code function in transfer settings for full script code...

The command to upload a file is put. You can place it instead of the "Your command 1" "Your command 2" placeholders like this:
"C:\...\WinSCP.exe" ... /command "open ..." "put C:\local\file.zip /remote/" "exit"
WinSCP GUI can generate a complete command-line including the put command for you:
Initiate a transfer in the GUI. You have to do it a way that pops up the Transfer Options dialog. The dialog does not typically show for drag&drop transfers (unless you opt for it in preferences). Instead, use the main menu or a file(s) context menu, a toolbar button or a keyboard shortcut.
On the dialog, drop down the menu at the Transfer Settings button.
Select the Generate Code command.
Generate Transfer Code Dialog opens.
On the Generate Transfer Code Dialog, select the Command-line format.

Related

How to have browser open for authentication automatically from Rscript run by batch file?

I created a shiny app in Rstudio that skims filenames from my dropbox. I use rdrop2 package for dropbox API access and authentication. When I run in Rstudio, the code rdrop2::drop_auth(new_user=T) will automatically open my browser to dropbox for authentication. That's all good.
I would like to run the whole app starting from a .bat file, as a simple way to avoid other users from needing to open R or Rstudio to access the app. I created a .bat file that simply runs my shiny app from R.exe. It looks like this
"path/to/R.exe" -e "shiny::runApp('path/to/shinyAppFolder', launch.browser = TRUE)" .
When this runs it does not automatically open my browser to dropbox for authentication, but instead provides a url in cmd. That output is below.
Removing old credentials...
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Please point your browser to the following url:
https://www.dropbox.com/oauth2/full_url_here
Is there a way to collect that url output from command and open it automatically using the batch file, or within the R script? Or any other methods to automatically open the url in the browser?
For a simple example, the below code can be run in a .bat file to produce the same results.
"path/to/R.exe" -e "rdrop2::drop_auth(new_user = T)"
It will bring up the same output as above.

How do I run SQL commands through Notepad++?

I am trying to start out using Notepad++ to run SQLite commands. I have tried following two brief YouTube tutorials to get me going. I can run the initial .bat file, but still cannot run the .sql file.
I have a Windows system environment Path variable set to the folder containing sqlite3.exe
"C:\Users\Adam\sqlite\"
I have saved the following file RunSQLite.bat in the folder containing sqlite3.exe
sqlite3.exe testDB.db
I have created a second file queries.sql
SELECT 34;
When I try to run queries.sql from Notepad++, using the RUN command:
C:\Users\Adam\sqlite\RunSQLite.bat "$(FULL_CURRENT_PATH)"
the only file that appears to run is RunSQLite.bat, giving the output:
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
sqlite>
Can anyone tell where I have gone wrong?
Thanks in advance.
aphopk
This C:\Users\Adam\sqlite\RunSQLite.bat "$(FULL_CURRENT_PATH)" will do exactly the same thing if run at the shell. RunSQLite.bat does not take any arguments so the Run command in npp is working as expected.
sqlite3 takes input from an external file with the .read command.
Path issues notwithstanding a bat file something like this should accomplish the task:
sqlite3.exe testDB.db ".read %1"
Notepad++ is a text editor, so you can now use it to edit your SQL file. After selecting the Language > SQL, Notepad++ will highlight SQL syntax as you type. Try typing some SQL, like
SELECT "Hi";
SELECT * FROM mydatabase WHERE id LIKE 'ID%';
You will see color, bold, and other possible formatting applied to the text you type. If you save the file as something.sql, and then load something.sql in your SQL client, the client will run the SQL commands from that file. If you have an existing somethingElse.sql file, you can open it in Notepad++, which will auto-recognize that it’s SQL and apply the syntax highlighting, allowing you to edit it and save it.
By using the Run > Run dialog, you can run an arbitrary command. For example, if your SQL client has a command-line mode accessed thru sqlclient.exe, you could type
c:\path\to\sqlclient.exe $(FILE_NAME)
If you just run it, that probably won’t show you any results… but if you ran
cmd /k c:\path\to\sqlclient.exe $(FILE_NAME)
It will open a new cmd.exe Windows command prompt, and show the output from that file.
If instead of running, you hit “SAVE”, you can give it a name (which will end up later in the Run menu), and/or a keyboard shortcut, so that you can easily re-use that many times.
If you want to do something more fancy, use the NppExec plugin, which includes a better batch/scripting language. Once again, you can save the NppExec script, and make it show up in the Macro menu.
If Python is a programming language you know or could learn (or if, like me, you know enough other programming languages that you can fake the Python), then the Python Script plugin will allow you to do even fancier stuff. (Python is a complete programming language, and has many libraries written, which could act as an interface between your SQL source file and your database engine; PythonScript has access to a full python2.7 interpreter. For example, you could write a script in Python which executes the commands from your SQL, grabs the results from your database engine, and displays them in Notepad++, either inline with your original SQL code, or in a new text document. You are really limited only by your imagination and knowledge of Python.)

Can I use a web based IDE like Eclipse che for connecting to a server maintained by my university for python programming ?

I want to edit the code through the IDEs text editor and debug and run it on the server.
Download Notepad ++ here
Download WinScp here
Connect to your school's server with winscp, then navigate to whatever file you would like to edit. Right click and set the default editor to notepad ++. Now everytime you open any file, you can hot edit inside notepad ++.
I know i perhaps strayed from your full request, but i like this method for quickly updating code and testing on the server.

TideSDK - How to run MyDaemon.php in background (async)?

How I can run MyDaemon.php in background in TideSDK app?
MyDaemon.php - it's my completely ready console software (a lot of code, run other my php scripts, run other software, etc). It's endless php script. It must be start after TideSDK APP and live all time before exit (while user don't close app). TideSDK show status from MyDaemon.php and have few buttons to control it.
Issue 1: How can I start MyDaemon.php in:
Ti.Process.createProcess("?path/to/php/from/tide? -f MyDaemon.php");
What write in "path/to/php/from/tide"? Target computer of my users don't have php package. I want run php from TideSDK like console mode. I include feature PHP and use button "Package with Runtime" in TideSDK Developer. I looked for all files inside TideSDK, but there are nothing like "php" (executing file), only libs.
Issue 2: I try to use
< iframe width=0 height=0 src="MyDaemon.php"></ iframe>
But TideSDK can't start UI APP, because can't take FULL source in frame. MyDaemon.php is undless. How can I include < IFRAME> in ASYNC mode like a real browser?
I try to use this trick:
<iframe width=0 height=0 src="" name="php">< /iframe>
<script>setTimeout("frames.php.location.href=MyDaemon.php", 1000)</ script>
But it's not work too (UI APP started, but halted after execute this frame).
MyDaemon.php can communicate with TideSDK APP any way:
start "/bin/php -f MyDaemon.php" and read/write stdin/stdout. MyDaemon.php can write to stdout any commands in JSON format.
start MyDaemon.php in and write to stdout < script>Ti...[commands]< /script> - any direct JS code for TideSDK
write any msg to file1 and read from file2 (TideSDK will read/write there and execute)
write any msg to SQLite DB (TideSDK will read DB on JS code)
Any other way.
It's important: MyDaemon.php want to start in console other php files! Because first process run a lot of childrens for calculating very long tasks. I can ask TideSDK for start this childrens and don't use "exec(/bin/php -f second.php)" in MyDaemon.php.
But I don't want to include double PHP binaries to my APP, because TideSDK APP already have it! It's a lot of extra space in dist.
Thank you and sorry for my language.
I think you should use Ti.Process.CreateProcess() function, where you can receive the output of the command you are using (I'm using JS syntax for this, not php, so I don't need to include extra libraries to execute commands, or write/read operations)
first you have a command cmd or shell command, lets say "ls -la /www"
then you need to send all the set of instruction as an array: var cmd = ["ls","-la","/www"]
then pass it to a var using Ti.Process.CreateProcess() : var echo = Ti.Process.CreateProcess(cmd);
to get the output, you could pipe out the content to another set of instructions.
the final program should look like this:
var cmd = ["ls","-la","/www"];
var echo = Ti.Process.CreateProcess(cmd);
echo.setOnReadLine(function(data) {
console.log(data);
});
echo.setOnExit(function(data){
console.log('process ended');
console.log(data)
});
echo.stdout.attach(echo.stdin);
echo.launch();
Instead console.log, you can pipe out the command output to your div.
also, besides main.html, you cannot load another scripts besides that. TideSDK is not a web based structured platform where you can reach a secondary page inside of the domain accessing it through url (like app://main.html is the only one to be loaded, have tried with no luck to call other "pages"), but instead modularize your app to load elements inside of the main page.
now, creating a daemon is a risk here. You need to be aware that depending on how you refresh the content it could increment severally the CPU usage.
I can suggest you to use a javascript loop to a shell command using the content above written. you do not need a real "daemon" or a secondary script since TideSDK can provide on certain extension that inside TideSDK

Microsoft Excel application can not access the file "..."

I don't what i dod uncorrect.
I did this steps:
To resolve this issue follow this steps
Login to the server as a administrator.
Go to "Start" -> "Run" and enter "taskmgr"
Go to the process tab in task manager and check "Show Processes from all users"
If there are any "Excel.exe" entries on the list, right click on the entry and select "End Process"
Close task manager.
Go to "Start" -> "Run" and enter "services.msc"
Stop the service automating Excel if it is running.
Go to "Start" -> "Run" and enter "dcomcnfg"
This will bring up the component services window, expand out "Console Root" -> "Computers" -> "DCOM Config"
Find "Microsoft Excel Application" in the list of components.
Right click on the entry and select "Properties"
Go to the "Identity" tab on the properties dialog.
Select "The interactive user."
Click the "OK" button.
Switch to the services console
Start the service automating Excel
Test you applica
tion again.
But i get another error - about "Retrieving the COM class factory for component with CLSID".
I loked this link http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91?prof=required
But it didn't help.
Excuse my harsh answer, but your problem is that you use EXCEL in a server environment. It was never build to support that. Microsoft advises against it, because there are many unresolved problems.
It would be better (and more stable and orders of magnitude faster) to use a library like EPPLUS to manipulate the excel files.

Resources