Sign in to follow this  
Followers 0
strate

Stdin and outs

10 posts in this topic

I am having problems with this. Its my first attempt at Stdin and outs. I basically made the example work for me except it doesn't work for me, lol. I have also found that there aren't enough search topics to help solve it either, help? What I wanna do is open to the path and then enter my string - ftp qaddb2.

Dim $line, $foo
$foo = Run(@ComSpec,'C:\windows\system32\', @SW_MINIMIZE,$STDOUT_CHILD + $STDIN_CHILD)
While 1
    $line &= StdoutRead($foo)
    If @error = -1 Then ExitLoop
WEnd
MsgBox(0, "STDOUT read:", $line)

;~ $foof = Run(@ComSpec,'C:\windows\system32', @SW_MINIMIZE,3)
StdinWrite($foo, 'ftp qaddb2')
;~ StdinWrite($foo)

;~ $foo = Run(@ComSpec,'C:\windows\system32', @SW_MINIMIZE,2)
$line = ''
While 1
    $line &= StdoutRead($foo)
    If @error = -1 Then ExitLoop
WEnd
MsgBox(0, "STDOUT read:", $line)

While 1
    $line = StderrRead($foo)
    If @error = -1 Then ExitLoop
    MsgBox(0, "STDERR read:", $line)
Wend

MsgBox(0, "Debug", "Exiting...")

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites



i asume you want to use ftp.exe to do something, why not just use my _FTP udf wich uses the build in wininet.dll

I've never seen those before, thanks.

What I need to do is get a file off of the server, and on to a local disk. It looks like none of those would help me with that though. Any other ideas?


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

I've never seen those before, thanks.

What I need to do is get a file off of the server, and on to a local disk. It looks like none of those would help me with that though. Any other ideas?

How about using InetGet, see help file for usage and example.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

I don't think that will do it either. All files for the individual user are saved on the server. In the users directory. We have to be logged into QAD (production program) for it to work. This is why I'm trying to use the command prompt. I can login thru it and make the transfer to my local disk. The real problem is finding out what the command prompt says.


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

Dim $ourNetview, $ourOutput, $ourFind, $ourWSs
$ourNetview = Run("net view", @SystemDir, @SW_HIDE, 2)
While 1 
    $ourOutput &= StdoutRead($ourNetview) 
    If @error = -1 Then ExitLoop
WEnd
$ourFind = Run('find /I "\\"', @SystemDir, @SW_HIDE, 3)
StdinWrite($ourFind, $ourOutput)
StdinWrite($ourFind)
While 1 
    $ourWSs &= StdoutRead($ourFind)
    If @error = -1 Then ExitLoop
WEnd
MsgBox(0, "Debug", $ourWSs)

I found this while searching for my answer. Does this respond only because the command prompt was closed? How does this work?


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

thought my old _FTPxxx.au3 sucked.

so i tryd using STD for it. but it failed.

googled a bit and came across an vb site that used a windows dll,

then i headed over to msdn to find out how to use em.

you could try to use my OLD ftp (see the link in my sig) witch calls ftp.exe with commandline parameters.

(there also is a addon for my DLL functions that adds FtpGetFile, search the support forum for "ftp")

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites

Dim $ourNetview, $ourOutput, $ourFind, $ourWSs
$ourNetview = Run("net view", @SystemDir, @SW_HIDE, 2)
While 1 
    $ourOutput &= StdoutRead($ourNetview) 
    If @error = -1 Then ExitLoop
WEnd
$ourFind = Run('find /I "\\"', @SystemDir, @SW_HIDE, 3)
StdinWrite($ourFind, $ourOutput)
StdinWrite($ourFind)
While 1 
    $ourWSs &= StdoutRead($ourFind)
    If @error = -1 Then ExitLoop
WEnd
MsgBox(0, "Debug", $ourWSs)

I found this while searching for my answer. Does this respond only because the command prompt was closed? How does this work?

I really would like to answer this question, but I think I'd rather make a StdxxxYyy FAQ instead... If you're asking why your previous code didn't work, Run-ning Run(@COMSPEC) as in your code above is just like running cmd.exe /c from the Windows Run... dialog, the command processor performs the action on the command line and exits; the command console didn't "stay around" long enough to accept your StdinWrite data. It's for this reason that the examples that you'll see on this forum are in the form of
Run(@Comspec & " /c foo.exe)

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

I really would like to answer this question, but I think I'd rather make a StdxxxYyy FAQ instead... If you're asking why your previous code didn't work, Run-ning Run(@COMSPEC) as in your code above is just like running cmd.exe /c from the Windows Run... dialog, the command processor performs the action on the command line and exits; the command console didn't "stay around" long enough to accept your StdinWrite data. It's for this reason that the examples that you'll see on this forum are in the form of

Run(@Comspec & " /c foo.exe)
Is there any possible way to keep it open or to read the text from one already open?

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

Is there any possible way to keep it open or to read the text from one already open?

Sure, you just have to run the program you want to read/write with in the Run function:
; Run the child program
 ; 7 in the last parameter means AutoIt connects to STDIN, STDOUT and STDERR
  $foo = Run(@ComSpec & " /c ftp.exe", @SystemDir, @SW_SHOW, 7)
  
 ; Write the desired commands + RETURNs to the child's STDIN
  StdinWrite($foo, "help" & @CRLF & "bye" & @CRLF)
  
 ; Loop until we get all the child program's output
  While 1
      $line = StdoutRead($foo)
      If @error = -1 Then ExitLoop
      MsgBox(0, "AutoIt3 Version " & @AutoItVersion & " STDOUT read:", $line)
  Wend
  
 ; Loop and collect any error messsages from the child program
  While 1
      $line = StderrRead($foo)
      If @error = -1 Then ExitLoop
      MsgBox(0, "STDERR read:", $line)
  Wend
  
  MsgBox(0, "Debug", "Exiting...")

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0