Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to pass a response to a .exe called by PoSh Expand / Collapse
Author
Message
Posted Wednesday, February 13, 2013 9:59 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 6:36 AM
Points: 402, Visits: 859
I'm calling an command line .exe from within a PoSh script.

This is generating a hit Y for Yes / N for No choice.
How can I send a Y in my PoSh script?

Thanks!



Post #1419634
Posted Wednesday, February 13, 2013 3:33 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 9:25 AM
Points: 7,070, Visits: 12,523
I think that is up to the program being called not PowerShell. If the program wants to accept input interactively and does not provide an input parameter for the information or a way to provide an "answer file" then I am not sure you can get around that.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1419759
Posted Thursday, February 14, 2013 7:08 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 6:36 AM
Points: 402, Visits: 859
Hmmmmm.

I found this on the net; the author plainly states it's a bit of a hack, but also claims to have made it work for him. I've not been able to get this to work myself.

#Pass the Y and exit
$PlinkCommand = [string]::Format('echo y | & "{0}" {1} exit',
$PlinkAndPath, $plinkoptions )
Write-Host $PlinkCommand
$msg = Invoke-Expression $PlinkCommand

Where
$PlinkAndPath is path to .exe, and
$plinkoptions are the parameters (username, password, hostname, etc)




Post #1420044
Posted Thursday, February 14, 2013 7:35 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 9:25 AM
Points: 7,070, Visits: 12,523
That's not a PowerShell thing per se. What that is saying is:

echo textToPipeIn | executableName executableOptions

Which works fine in cmd Shell as well. How to pipe in more than one answer with that syntax though?


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1420059
Posted Thursday, February 14, 2013 7:46 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 6:36 AM
Points: 402, Visits: 859
Yeah, I know it's a cmd hack, and you're right, it'll only work for a single response.

In my particular case, that's all that would have been required.

I got around it per your suggestion by using another switch.

Thanks!

P



Post #1420072
Posted Thursday, February 14, 2013 8:05 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 9:25 AM
Points: 7,070, Visits: 12,523
Good deal. Thanks for posting back that it was sorted.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1420095
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse