Active IQ Unified Manager Discussions

WFA to execute unix scripts on a unix server

ANEESH235
8,040 Views

Can WFA  workflows execute  unix  scripts on a unix server . If it can execute script  do you have a  working example

10 REPLIES 10

ag
NetApp
7,986 Views

Hi Aneesh,

You can definitely execute a unix script/command remotely and capture the output.

I do not have an example script or the exact way of doing it but here is what you can try:

I am assuming you have the script on the WFA machine.

Create a new command that makes use of the tool 'plink' to connect to a remote machine. Something like this:

$cmd = `C:\plink.exe -ssh -m C:\checkspace.sh name@ip -pw password ` > C:\output.txt

source:https://groups.google.com/forum/#!topic/microsoft.public.windows.powershell/sDJZtr9qUfk

I haven't checked the correctness of the command yet. For the powershell syntax, you can check other commands.

In case you need help with creating the command, let me know.

I suggest you first try the command from the PS CLI.

I will try to explore for a better answer for you.

-Anil


rle
NetApp Alumni
7,986 Views

HI Aneesh,

You should also be able to create a command that performs SSH directly to the UNIX box.  You can use PowerShell or Perl to make the connection.

Regards,

   - Rick -

sinhaa
7,986 Views

Aneesh,

       WFA can do anything that a powershell and .NET can do and a powershell can do (almost) anything. You don't need any external tools or APIs. You can use Invoke-NaSsh cmdlet to get this done.

Attaching the .dar file which is a WFA command to do it. This .dar can be imported on WFA2.0.1 or above.

Command Code:

=================

param (

  [parameter(Mandatory=$true, HelpMessage="Unix Command or Script Path")]

  [string]$Script,

  [parameter(Mandatory=$true, HelpMessage="Unix Host Name")]

  [string]$UnixHost

)

try {

          $creds =  Get-NaCredentials -Host $UnixHost

}

catch  {

          $creds =  Get-WfaCredentials -Host $UnixHost

}

$returnData= Invoke-NaSsh -Name $UnixHost -Credential $creds -Command $Script

Get-WFALogger -Info -Message $returnData

======================

sinhaa

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

ANEESH235
7,986 Views

Do i need to create a passwordless ssh between the WFA server host ( windows server ) and the target unix server  to exeute this workflow . How can the workflow get the target unix host credentials .

sinhaa
7,986 Views

No Aneesh. This doesn't require passwordless login. You can set the credentials of your Unix Host at tab "Execution" => "Credentials" . If you read the description of this command, it tell you where to save the credentials.

1. Add Credentials

2. Match: Exact

3. Type: Other

4. Give username and password.

5. Save it.

See the image below.

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

calori
7,986 Views

May I use this procedure to execute a remote script in Windows too ?

sinhaa
7,986 Views

Yes, only you need to have SSH server ( e.g. Openssh or FreeSSHD etc.)  running on your windows host.

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

SURESH_SENNIAPPAN
7,986 Views

Is there any example workflow for calling unix script from WFA ? If means can any one share ?

sinhaa
7,986 Views

I've already attached the .dar file for the command and also the command code along with the instructions how to use it. You need anything else?

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

SURESH_SENNIAPPAN
6,085 Views

i need an example workflow to call the  script from the unix server.

Public