Redirecting output from plink

I am currently trying to write a function that runs plink and captures the output from that process.  When I try StandardOutput I get nothing and when I try StandardError I get "Unable to read from standard input: The handle is invalid."  I can only assume that this means I am trying to read while plink is waiting for input.  I am also passing my command via a text file called apCommands.txt.  When I run this command manually it works and gives me the required output, I just can't figure out why I can't redirect that output so I can store it in a results file.  Here is the code I have right now.
string pArgs = "-m \"" + ABSPATH + "\\apCommands.txt\" -ssh myHost -l user -pw password";
string output;
if (File.Exists(ABSPATH + "\\apTest.txt"))
File.Delete(ABSPATH + "\\apTest.txt");
StreamWriter apTest = new StreamWriter(ABSPATH + "\\apTest.txt");
Process runAP = new Process();
ProcessStartInfo apInfoStart = new ProcessStartInfo(ABSPATH + "\\plink.exe");
apInfoStart.Arguments = pArgs;
apInfoStart.RedirectStandardOutput = true;
apInfoStart.CreateNoWindow = true;
apInfoStart.UseShellExecute = false;
runAP.StartInfo = apInfoStart;
runAP.Start();
output = runAP.StandardOutput.ReadToEnd();
runAP.WaitForExit();
apTest.WriteLine("Standard Output");
apTest.WriteLine(output);
apTest.Close();
runAP.Close();
Thanks,
Joe

I see.  I wasn't aware that it wasn't a reliable way to connect to ssh.  As for the error message that was from standardError.  I think the process may have been waiting for input when I was trying to read from StandardOutput and thats why I got that error message.  Also instead of redirecting StandardOutput I tried redirecting the output directly into a file by running a cmd process and passing the commands I wanted to run through StandardInput.  The underlined section is all I changed besides running this inside of a cmd process.  This did work for me but I would rather know how to do it using StandardOutput. 
string dArgs = "cd \"" + ABSPATH + "\"";
string pArgs = "plink -ssh myHost -m \"" + ABSPATH + "\\apCommands\" -l user -pw password > test.out";
Process runAP = new Process();
ProcessStartInfo apInfoStart = new ProcessStartInfo("cmd");
//apInfoStart.Arguments = pArgs;
apInfoStart.RedirectStandardInput = true;
apInfoStart.RedirectStandardOutput = true;
apInfoStart.CreateNoWindow = true;
apInfoStart.UseShellExecute = false;
runAP.StartInfo = apInfoStart;
runAP.Start();
runAP.StandardInput.WriteLine(dArgs);
runAP.StandardInput.WriteLine(pArgs);
I haven't tried reading the StandardOutput from this piece of code, but I will probably try it.
Thanks,
Joe

Similar Messages

  • Redirecting output from launchd?

    I'm in the process of converting my existing cron tasks over to launchd and encountering a small-ish annoyance. I've gotten into the habit of writing cron commands like this, appending the output to a log file:
    some_command andaparameter >> /the/full/path/to/the/logfile.txt
    This just gives me a quick-and-dirty way to log activity from cron commands. When I do that in launchd, it doesn't go the expected location, but rather gets written out to the system log. Does launchd not support >> redirection like that or do I need to do it in some other way?

    An excellent gui shell is lingon http://tuppis.com/lingon/
    Apple Tutorial: Getting Started with launchd http://developer.apple.com/macosx/launchd.html
    launchd in Depth: http://www.afp548.com/article.php?story=20050620071558293
    launchd: One Programm to Rule Them All – Video presentation of launchd: http://video.google.com/videoplay?docid=1781045834610400422
    I've looked around on the web for a good run-down of what it can do and some examples, but found very little. Seems like a great tool. I'm surprised there aren't more examples and tutorials out there showing what it can do.

  • Redirecting output from 'cmd.exe /c'

    I am using Powershell 2009 on a WIN-Server 2008 R2
    I have seen several suggestions on how to "redirect" the output generated by a 'cmd.exe /c', but none of the suggested solutions were successful.
    I have a simple cmd
    cmd.exe /c my_program.cmd $file.basename
    This process creates a lot of screen output and this command is in a loop of all files in a directory.
    I want to capture the output to a file "$lgfile"
    I have used
    {content}
    >> $lgfile
    {content}
    Out-file -filepath $lgfile [no output]
    {content}
    `$lgfile 2`>>`&1 [error '&" is reserved for future use]
    I would be grateful for any suggestions
    Also, the reason I am using "cmd.exe /c" is because that is the only method i have been able to use successfully (my_program.cmd is calling an ORACLE compiler! and all other methods to execute this compiler did not work except as a cmd-file)

    I usually just pipe to Set-Content:
    cmd.exe /c my_program.cmd $file.basename | Set-Content $lgfile
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • Redirect output from "do script" routine

    Don't know about you, but I find nothing more frustrating than having syntax that I worked out successfully at a previous time, but can't reconstruct now!
    The present dilemma:
    I'm doing a "do script" routine (not a do shell script routine) where I want to redirect the output to a desktop file, but I haven't been able to get the redirect syntax correct.
    Entered in Terminal directly, the command and redirect work fine; the pertinent part of the command is:

    Then it would help if you posted the command you're trying to use.
    The chances are it's an issue of escaping - certain characters need to be escaped in AppleScript as well as the shell in order for them to work. But in general, this should work:
    tell application "Terminal"
    do script "/path/to/command -option -otheroption > /path/to/output"
    end tell

  • Redirect output to jsh

    Hi there!
    I am working on a simple java shell in Windows XP at the moment which simply parses an entered command and passes it to ProcessBuilder as a list.
    It works ok - the process startsas expected - the only problem is I cannot see any output from the processes, nor can I figure out a way to redirect STDOUT to the running java shell from XP (which is what I really want).
    Here is my code so far - as I said, it's fairly basic at the moment.
    public class shell {
         public void start()throws java.io.IOException {
              String commandLine;
              BufferedReader console = new BufferedReader
              (new InputStreamReader(System.in));
              while(true)  {
                   System.out.print("jsh>");
                   commandLine = console.readLine();
                   if(commandLine.equals(""))
                        continue;
                   else process(commandLine);
                        continue;
         private void process(String cmd)
              String command = cmd;
              String[] commsplit = command.split("\\s");
              ProcessBuilder pb = new ProcessBuilder(Arrays.asList(commsplit));
              try {
              pb.start();
              catch (IOException ioe) {
                   System.err.println("Unknown command or input. Please try again");
         public static void main(String[] args)throws java.io.IOException {
              shell shell1 = new shell();
              shell1.start();
    }Any pointers in the right direction would be most appreciated.

    You need to process the stdout and stderr of the Process. This http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html shows you how to do it safely!

  • Redirecting output in Netbeans?

    After a few years of several languages, I am finding Java to be my home :) I really enjoyed the improvements that Sun has made with NetBeans 6. However, it doesn't output text to the console/command-prompt like it would in JCreator Pro. Even in JCreator Pro, I had to redirect the output and it was much easier given a few settings. For Netbeans, the output goes to an "Output Window." I find writing my ascii game is easier with the command prompt and so JCreator seems ideal if I can't get my preferred IDE set properly for the command prompt. Is there a way to get NetBeans to redirect its output from the Output Window to the command prompt? Thanks.

    I was able to get the "run" button to execute output to the console (command prompt). Doing so was not too difficult. I agreed with Leonardo that posting it here would be helpful for someone else. He was very helpful with our first few attempts on a similar task.
    In your workspace, click on the Files tab. Find build-impl.xml, double-click on the "run" property in the navigator window. It should bring you to something similar below. What I added was the "exec" open and end tags. Just paste this in there and you will be up and going.
    <target name="run" depends="init,compile" description="Run a main class.">
    <j2seproject1:java>
    <customize>
    <arg line="${ application.args}"/>
    </customize>
    </j2seproject1:java>
    <exec executable="cmd">
    <arg value="/k" />
    <arg value="start cmd /k java -classpath "${basedir}\${ build.classes.dir}" ${main.class}" />
    </exec>
    </target>

  • Subwoofer output from ZS Notebook to Recie

    Hi. I needed to boost my subwoofer's output from my soundcard to my reciever. The cable that I use to connect from my SB Audigy2 ZS Notebook to my Sony STR-DE898 is a Creative Labs Home Theater Cable with 8 RCA plugs. The subwoofer I use is from an Inspire T7700 and I'm using it as an acti've subwoofer, which connects from the Sony STR-DE898's subwoofer output to the RCA plug of a T7700 subwoofer marked Subwoofer in the back. Setting the volume to the max isn't a problem because I can adjust the bass level in the T7700's remote. I don't have the bass level at max (I set it to about 40% from hte minimum position) but when I go into Multi In mode in my reciever, I have to have the bass level at max but creates a hum. I can barely hear the subwoofer. Even turning on the Bass Redirection in my Speaker Settings doesn't help! Boosting the bass in Surround Mixer and increasing the 25Hz frequency in the EQ affects all the speakers so that's not an option. Any ideals? Any low-cost RCA-in->RCA-out amplifiers?out there which will boost my subwoofer output? The ZS Notebook will go through the amp to my Subwoofer In of my STR-DE898 reciever. Thanks.

    You just saved me from starting a new post... exact same problem I'm having. Were you able to solve it?
    Only difference for me is:
    * Pioneer 7.1 receiver with 7.1 speakers, and it receives a PCM 2.0 channel signal from my mac mini late 2012. Can only hear sound out of L+R speakers
    * I also only get 2 channels for video through XBMC, as well as iTunes music playback
    If I change my midi setup to 2 channel instead of 8, I can change my audio settings on the receiver to acheive "multichannel", but still nothing coming out of the subwoofer. So I'm getting 7.0 not 7.1. But don't see why I need to resort to this if Mac OS and Mac mini claim they support multichannel audio through HDMI. And I too rely heavily on the subwoofer, so this work-around is useless to me.
    Was just told to first try to reset the Mini (unplug for 30 secs) and PRAM reset (Command+Option+P+R). Will try that when I get home later today.

  • Discoverer report - Output from Discoverer plus is not the same as Discoverer desktop

    As a part of Upgrade project we are migrating the discoverer reports from 11i (11.5.10.2) to R12 (12.1.3) .After migrating to R12, for a custom discoverer report the output given by discoverer desktop is correct (24 rows for a scenario). But the report output from Discoverer plus does not show the credit transactions (2 rows). The output from Discoverer plus shows only 22 rows (24 - 2), which is incorrect. The query is the same in Discoverer desktop and Discoverer plus.
    Please let me know why these transactions that are appearing when the report is run from discoverer desktop are not appearing in discoverer plus. Is there any setup in discoverer plus for this?
    Regards,
    Brajesh

    Pretty hard to answer a question like this.  Best bet would be to copy the existing discoverer plus book and start removing conditions, fields, etc until those two rows from desktop show up and see if you can work it out. 

  • Unable to output from FCP to Canon XL1.

    I have an eMac with Final Cut Pro 4.5 HD. I also have a Canon XL1 3 CCD camcorder.
    I have no problem capturing footage from my camcorder to my eMac on FCP. I can also connect my Canon to my VCR and record off my camcorder to my TV, as well as play the tape on my camcorder to watch it on TV.
    However, I cannot output from FCP to my camcorder. The 4 to 6 FireWire is attached to both the camera and the eMac and I checked the Log and Capture feature and FCP does recognize a camera or deck is attached. I've been trying to output it using manual record in which I press record on my camcorder and play the playhead on FCP. As I record, there is no picture on my viewfinder, nor any audio being recorded and when I play it back, I just get this blank blue screen, but the timecode is recorded.
    Am I missing something here?

    ensure the following are set
    View>Video Playback>Firewire Apple 720x480 (NTSC or PAL - whatever is appropriate)
    View>Audio Playback>Audio follows video
    View>External Video>All Frames
    If this isn't what you are set to do, you won't be sending video out to your recorder.
    x

  • How to Generate CSV Output from JD Edwards BI Publisher

    Hi All,
    I have a report "Critical Date Report" - R15611 in JD Edwards 8.11. This report has to be generated as CSV output from BI Publisher which is embedded to JDE.
    The purpose we want use BI Publisher is to move some of the data displaying to different place in the page(ex: Move the company address from top left corner to Bottom right corner).
    In order to achieve this
    1.We created blank rtf template and upload to XML repository using P95600 application
    2.Create report definition using P95620 application
    3.Here I see the available output types as PDF,RTF,HTML,EXCEL,POWERPOINT and XML,ETEXT(GRAYED OUT)
    Which output type we can use for CSV ?
    4.Execute the report definition of the critical date report from P95620 to get the XML source
    5.This XML source will be loaded into the blank rtf template
    6.From this point no idea how to design the rtf template in order to get the CSV output.
    7.We did design and output type as excel - but the result data is not in good formatting and alignment*(Headers and footers are repeating).*
    If any one has worked on similar type of requirement,let us know how to do or send a sample XML source,rtf template and how the CSV output will be. Or any document link present in Oracle site will be helpful. Please let me know if you need more details.
    Thanks in Advance.
    Vijay

    Hi Vijay,
    For CSV output, you need an E-text template (not RTF) that's why its grayed out! You can use Excel as output type and have (No headers and footers) , then you can open the file in Excel and store it as CSV. Does not always display correctly though.
    Why are you compelled to use BI publisher? you can use the JDE standard csv output report, (as is used by most EDI systems) of course this may involve a bit of customization if you wants the fields arranged differently.
    -Domnic

  • Error message by periodic weekly: No output from the 1 file processed

    Hi there,
    since four weeks, I got a problem with the maintenance script periodic weekly. Up to December 22nd, the script did, what it should do: rebuilding the database of locate and whatis, rotating log-files. Since one week later, I got the error message: No output from the 1 file processed.
    Normally, I use Anacron to do the job. When I noticed the problem, I tried to start the script with Tinker Tool System getting the same result. Another try using the Terminal (sudo periodic weekly) also failed. The commands locate and whatis are working, locate.updatedb and makewhatis also. I'm running 10.4.8; in the past, I did not have such problems. Anyone with an idea or solution?
    Thanks
    Klaus
    MacBook Pro   Mac OS X (10.4.8)  

    Hi Gary,
    here is the output you were asking for:
    Last login: Thu Jan 25 20:03:55 on console
    Welcome to Darwin!
    DeepThought:~ dirk$ sudo /private/etc/periodic/weekly/500.weekly; echo $?
    Password:
    Sorry, try again.
    Password:
    Rebuilding locate database:
    Rebuilding whatis database:
    find: /usr/local/man: No such file or directory
    makewhatis: /usr/share/man/man1/fetchmailconf.1.gz: No such file or directory
    Rotating log files: ftp.log lpr.log mail.log netinfo.log ipfw.log ppp.log secure.log
    access_log error_log
    Running weekly.local:
    Rotating psync log files:/etc/weekly.local: line 17: syntax error near unexpected token `)'
    /etc/weekly.local: line 17: `if [ -f /var/run/syslog.pid ]; then kill -HUP 0 80 79 81 0cat /var/run/syslog.pid | head -1); fi'
    2
    DeepThought:~ dirk$ ls -loe /private/etc/periodic/weekly/500.weekly
    -r-xr-xr-x 1 root wheel - 2532 Jan 13 2006 /private/etc/periodic/weekly/500.weekly
    DeepThought:~ dirk$
    It seems, Rogers idea, PsynX respectively the deficient uninstalling by me is responsible for my problems, is correct. Should I remove the whole file weekly.local or should I only remove the content? I prefer removing the whole file, because it was created while installing PsyncX. The date of creation is the same as the date of installing the app (December 25).
    Klaus
    By the way: it seems to me, the solution of my problem is in sight. So I want to thank you all for the amazing aid I got from you!

  • Changing the seeded rdf report output from text to PDF

    Hi All,
    I am trying to change the seeded report "Print Requisition Report" output from text to PDF. I changed the output format in the concurrent program definition from text to pdf. The report is now getting displayed in pdf format, but the alignment of the fields are changed. The output is not printing as it was printing while in the text output format. The output looks very sloppy, with uneven fonts and too much of text wrapping.
    I tried some formatting and fields are somehow getting displayed but doesnt look in proper format. I am not able to change the font style in the report builder 6i, even if i change it is printing in the same font style with uneven font size. I think reducing the font size might help, but i am unable to change.We are on 11.5.10.2. Please provide your valuable suggestions on how to go about.
    Thanks
    Sarvesh

    Hi Hussein,
    Thanks for the information. After the adjustments in the layout and the font change the report is now getting displayed without any clipping when clicked on view output. But when the same report is printed some characters on the left and and right side is getting clipped. Please help on how to solve this issue.
    Thanks,
    Sarvesh

  • How to capture graphical outputs from other programs

    Does anyone know how we capture the graphical outputs from the other programs and show them
    on the swing?
    I'd like to use a java program to run gnuplot, capture the outputs, and show them using swing.

    Depends on what you mean by "graphic outputs".
    Taking a quick glance at the gnuplot homepage, it looks as if you can output to PNG files, so just run the app, and load the png file.

  • JDev generated webservices encodes XML output from PL/SQL procedure

    I have a PL/SQL packaged procedure which takes some input parameters and produces one output parameter. The output parameter is of type CLOB and after the procedure has run, it contains a big piece of XML data.
    Using JDeveloper 10.1.3.1, I've published this packaged procedure as a webservice. The generated webservice is fine and works, except for one tiny little issue: the XML that is taken from the output parameter is encoded.
    Here is an example of the SOAP message that the webservice returns:
    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ns0="http://gbv0300u/GBV0300U.wsdl/types/"><env:Body><ns0:gbv0300uResponse
    Element><ns0:result><ns0:obvglijstOut> & gt;type>GBV0001& gt ;/type& lt;
    & gt;diensten& lt;
    & gt;dienst>some value& gt;/dienst& lt;
    & gt;/diensten& lt;
    </ns0:obvglijstOut></ns0:result></ns0:gbv0300uResponseElement></env:Body></env:Envelope>
    (I've manually added an extra space between the & and lt; or gt; to make sure a browser will not translate it into a < or >!)
    The contents of the <ns0:obvglijstOut> element are filled with the output parameter from the PL/SQL package.
    How can I change the generated webservice, so the output from the PL/SQL package is used as is instead of being encoded?

    Update: I've tested a bit more by adding some output statements to the java code that JDeveloper generated. I'm now 100% sure the PL/SQL code gives the XML data correctly to the webservice.
    At this moment my guess is that somewhere in the WSDL definition there is something that enables the encoding of the data. But I'm not sure.
    Any help is greatly appreciated.

  • Can MainStage split the audio outputs from a plug-in to separate busses/out

    Take EXS24 or Battery 3 or Kontakt as examples
    Only one plug-in instantiated but each drum 'hit' sent to separate outputs from within the plug-in/VI and brought into the mix on Audio/Aux channels for separate processing.
    It's easy to set up in ProTools and Logic.
    (I don't want to send the output of the channel strip to a bus - I know how to do that)
    I've read the manual so many times and can't find any answers.
    Does MainStage actually allow this routing ?
    Thanks for any help
    Lee

    As far as I know, the only way to do what you want in MainStage is to set up an EXS24 for each output.
    The EXS24 does have an option to load with multiple outputs, but I haven't found a way to make it work on my set up.

Maybe you are looking for

  • Setting up printer sharing with a Windows Vista printer

    I am new to the Mac world and have been trying to set up printer sharing between my Macbook and HP PC. I have two HP's that I have been successful in sharing a printer with, but I can not figure out how to get the Macbook connected. I have read a num

  • How do I install a second iPod onto my computer?

    I have a 40GB iPod already subscribed to my computer. I recently bought an iPod Nano for my girlfriend. How can I download music from my existing iTunes to her iPod (ie. have 2 iPods sharing the same computer? Thanks Dell 4700   Windows XP Pro  

  • Customer Clearing on Electronic Bank Statement

    Hi, I am facing a problem to clear the customer open items. Let me explain the situation. The is an invoice on the Customer Account. The entry is: Customer A/c    Dr.   100 Sales A/c          Cr    100 Now, I have received a bank statement, when I po

  • Account determination as per note 1032265

    hi good morning every one please let me know as per master note 1032265 and MM-Tax-config.zip. please go through the file MM-Tax_config.zip. it is available in note 1032265. For account determination they mentioned in MM-Tax-config.zip file "add new

  • Unable To Process CJV4 Standard Transaction

    Hi Friends, I am trying to Tranfer Project through CJV4  Standard Transaction In Ecc6 it is going to Dump at the select query  in two different Servers(IDES) Is there any patch we need to apply, as there is no modifications done to the standard one.