aiParameter.sh|cut -d "=" -f 2`

aiParameter.sh|cut -d “=” -f 2`

This is the text i would like to store in an string variable,but its showing some error showing left hand side of an assignment must be an variable,property or indexer .please resolve

had you tried:
Assign Activity
strCommand | string Variable =
"aiParameter.sh|cut -d ""="" -f 2"

Yes but in the last the code contains 2’

Please elaborate more on what was done and what is needed

UPD1 -
for an ' at the end we would just include it
"aiParameter.sh|cut -d ""="" -f 2'"

But with the copy and paste for you samples you have to check, what in detail is needed as a ` was presented

@rakeshcm456/@Rakesh_C_M ,

Assign like this.
strVariable = “aiParameter.sh|cut -d “”=”" -f 2`"

Thanks,
Ashok :slight_smile:

“aiParameter.sh|cut -d “”=”" -f 2’"

When i try to use it, It is showing the error like ERROR Validation Error ; expected
Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement MOPS/79_MM Implementation in CFX/Check_ActiveCFX.xaml

1 Like

Assign like this.
strVariable = “aiParameter.sh|cut -d “”=”" -f 2`"

When i try to use it, It is showing the error like ERROR Validation Error ; expected
Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement MOPS/79_MM Implementation in CFX/Check_ActiveCFX.xaml

@rakeshcm456 Hope it will help you, and you should know why it is happening, I have added additional tips on the post
Understanding the Error:

The error “left hand side of an assignment must be a variable, property, or indexer” indicates that you’re trying to assign a value directly to the output of a command in UiPath. UiPath requires the left side of an assignment to be a variable that can store data.

Solution Steps:

  1. Import the System.Diagnostics Namespace (for UiPath):

    • In your UiPath project, use the Import Namespace activity to include System.Diagnostics. This namespace provides tools for interacting with system processes, including executing shell commands.
  2. Create an Assign Activity:

    • Drag and drop an Assign activity onto your workflow. This activity allows you to assign values to variables.
  3. Use the Invoke Command Line Activity (for UiPath):

    • Before the Assign activity, add an Invoke Command Line activity.
    • Set the Command property to "aiParameter.sh | cut -d "=" -f 2". This executes the shell script aiParameter.sh and pipes its output to the cut command, which extracts the second field (after the first equal sign) from each line.
  4. Capture the Output (Assign Activity):

    • In the Assign activity:
      • Set the To property to a string variable (e.g., outputString).

      • In the Value property, use the following expression:

        process.StandardOutput.Trim()
        
        • process is a variable automatically created by the Invoke Command Line activity to store process information.
        • StandardOutput property retrieves the standard output of the command.
        • .Trim() removes any leading or trailing whitespace from the output.

Explanation:

  • The Invoke Command Line activity executes the command and captures its output.
  • The Assign activity assigns the trimmed output (second field of each line) to the outputString variable.

Additional Considerations:

  • If aiParameter.sh might generate errors, consider incorporating error handling using a Try Catch block around the Invoke Command Line activity.
  • You can modify the cut command’s arguments (e.g., -d ":" -f 1 for colon as delimiter and first field) to suit your specific needs.

Alternative for Standalone C# Applications (if not using UiPath):

If you’re working outside UiPath, you can use the System.IO namespace:

  1. Import the System.IO Namespace:

    using System.IO;
    
  2. Execute the command using Process.Start:

    string command = "aiParameter.sh | cut -d “=” -f 2";
    string outputString;
    
    using (Process process = Process.Start("bash", $"-c \"{command}\""))
    {
        process.WaitForExit();
        outputString = process.StandardOutput.ReadToEnd().Trim();
    }
    // Use the outputString variable as needed
    

Remember to escape the double quotes (") inside the command string for proper execution.

By following these steps, you’ll successfully store the desired output from the command in a string variable, resolving the assignment error and enabling further processing within your UiPath workflow or standalone C# application.

Assign like this.
strVariable = “aiParameter.sh|cut -d “”=”" -f 2`"

When i try to use it, It is showing the error like ERROR Validation Error ; expected
Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement MOPS/79_MM Implementation in CFX/Check_ActiveCFX.xaml
[/quote]

Give me your Xaml file or use it below code it solve your issue

string Variable = @"aiParameter.sh|cut - d “”=”\"" -f 2";`

You string not proper format @rakeshcm456

hi @rakeshcm456 not sure if that’s what you need - but do you need that?

image

see bottom left

cheers

TestDump1

@rakeshcm456 You need to use the \ before \"" -f 2 " which solve your issue

"aiParameter.sh|cut - d “”=”\"" -f 2 ";

cmcli disp ‘grep -w uniqueid /tspinst/scripts/aiParameter.sh|cut -d “=” -f 2’

I am using c

use bleow text in

"aiParameter.sh|cut -d \""="" -f 2'"

cmcli disp ‘grep -w uniqueid /tspinst/scripts/aiParameter.sh|cut -d “=” -f 2’

Please use this text and try to save this in variable.

"grep -w uniqueid /tspinst/scripts/aiParameter.sh|cut -d ""="" -f 2'"

hi @rakeshcm456 i’m pretty sure the problem is that you’re using different quotes.

“ and " - please only use "

cheers

if you zoom in in your editor it becomes more obvious