I have a WinSCP code written for some file transfer ... That's working fine.
My requirement is: before I exit from WinSCP console, I want to execute another batch to take a screenshot of that WinSCP console and then I want to say bye to the WinSCP console. But as long as the second operation is not complete, I don't want to exit the WinSCP console.
I tried:
winscp> Call %some_path%\test.bat
but it says some error like:
The call command executes the command on the server.
You cannot execute local commands from WinSCP script.
But you can execute WinSCP from a batch file and take a screenshot from the batch after WinSCP finishes. Make sure that you execute the winscp.com (not the winscp.exe). The winscp.com is a console application. It inherits the console of the parent batch, so you do not loose WinSCP output after it finishes.
winscp.com /script.txt
%some_path%\test.bat
Anyway, I do not really understand the purpose of this. Wouldn't it be better, if you redirect the output of the winscp.com to a log file?
winscp.com /script=script.txt > output.txt
Or maybe even better, use a log file (the /log=<path> command line parameter). The log includes whole output of the WinSCP console, and lot more.
Related
It is possible to pipe the console output of an intellij application to a bash command so I can pretty-print it on the console directly?
I know I can save the log output to a file, but I still want to keep it on the stout window only, but just parse it through a script.
Piping output is a feature of the terminal shell.
IntelliJ IDEA is not using a terminal to run your app, therefore it's not possible with the default Run/Debug configurations.
You could use an external tool that will open a command line shell and run your app there, but the shell has to be open in a separate window and it will not be possible to get the formatted output directly in the IDE.
There is a related feature request in YouTrack, but it's unlikely to be implemented soon.
I would like to make a batch file that can write sql request into an .exe that is running as a cmd prompt window.
My idea was to put my sql script into an .txt file that the batch request and insert into my second prompt window.
I've found something about:
Type 'mytext.txt' | myexe.exe
But its not working.
What I want to do is a Batch that send my sql request into that .exe run as a cmd prompt, so I can automate that process.
Any idea?
Thanks
Depends heavily on the capabilities of that exe-file.
What does it poll for ? Is it written to handle pipes ?
https://technet.microsoft.com/en-us/library/bb490982.aspx gives you an overview of the command redirection operators.
Not knowing what the exe is capable of makes this question really hard to answer.
I have a scheduled task using Windows 7 to run a .exe file at a specific hour, which in-turn creates a .txt file and saves it in a folder. I am trying to write a script that will automatically send this .txt file to a FTP server without me using cmd.
I am working with this script thus far
open ftp.site.com
username
password
put c:\folder\file.txt
quit
FTP doesn't require CMD. It can run in it's own console window.
FTP /? shows
-s:filename Specifies a text file containing FTP commands; the
commands will automatically run after FTP starts.
The script file contains exactly what you would type interactivly.
Supposing your current scheduled task runs a command like:
c:\folder\someapp.exe c:\folder\file.txt
Change that to
c:\folder\script.bat
Where the c:\folder\script.bat batch file will look like:
c:\folder\someapp.exe c:\folder\file.txt
ftp.exe -s:c:\folder\ftp.txt
And the c:\folder\ftp.txt will contains your FTP script:
open ftp.site.com
username
password
put c:\folder\file.txt
quit
I want to automate the export process which I take using expdp command in Oracle.
Following is the contents of batch file I have created to open PuTTY.
#echo off
"C:\Program Files\PuTTY\plink.exe" username#Ip_Addr -pw password -m Open_Putty.txt`
Following is the contents of Open_Putty.txt to execute different commands.
echo $ORACLE_SID;
Read oraenv;
But after opening Open_Putty.bat it disappears without showing any output.
Please help me with this. I want to set oraenv and run some more commands to take the backup.
It's unlikely that plink.exe disappears without showing any output. I assume you execute the batch file from a Windows Explorer or other GUI application, so the Plink console window disappears once Plink finishes (possibly with error) and you cannot read the output (error).
Make sure you execute plink.exe from a console window (typically a cmd.exe) or add pause command to the end of the batch.
Make sure Plink can find the script file (Open_Putty.txt). As you do not specify a path to the file, it has to be located in your current working directory. Safer is to use a full path to the script file:
"C:\Program Files\PuTTY\plink.exe" username#Ip_Addr -pw password -m "C:\path\Open_Putty.txt"
The backtick symbol at the end of the command should probably not be there.
The name "Open PuTTY" is bit confusing. You are not using PuTTY at all. And even if you refer to Plink by "PuTTY", your script file (Open_Putty.txt) is not opening PuTTY nor Plink. It's executing remote commands. So you should better name it export.txt or similar.
I am writing a BASH deployment script on RH 5. Script runs great and send out an email at the end of the script run. However, what I need to do is, at the end of the script, if I detect any failure, I need to copy log files back local server to attach to the email.
Script can detect failure fine, how to copy log files back. I don't want to just cat the log files as they can be huge.
Any suggestions?
Thanks
S
If I understand correctly your problem, you should use scp
http://linux.die.net/man/1/scp
and here you can find how to automate the login so you can use it in a script
http://linuxproblem.org/art_9.html
I can't see any easy way of avoiding a second login with scp/sftp. If you're sure that it's only the log file that will be returned you could do something like the following:
ssh -e none REMOTE SCRIPT | gzip -dc > LOGFILE
Inside SCRIPT you have something like gzip -c LOGFILE when if fails.