Skip to content

Unable to execute command on Linux #61

@maciejmatuszak

Description

@maciejmatuszak

Hi I am trying to execute uv command using App.ExecuteCommand when log with specific pattern is detected.
the App.FindCommandPath("uv") is able to find full path to command but executing it gives Command '/home/macma/.local/bin/uv' not found. [Line 2] CarinaStudio.AppSuite.Scripting.ScriptException: Command '/home/macma/.local/bin/uv' not found.

The executable has correct permissions:
parent dir has drwxrwxr-x
and uv executable has rwxr-xr-x

Any ideas?

ULogViewer Log

2025-08-15 13:29:21.6663 22344    16  INFO Script[CooperativeLogAnalysisScriptSet]: cmd_full: /home/macma/.local/bin/uv
2025-08-15 13:29:21.6669 22344    10 ERROR RoslynBasedScript-15: Error occurred while running script
2025-08-15 13:29:21.7433 22344     1 DEBUG FileLogDataSource-6: Change state from Preparing to ReadyToOpenReader
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]: Command '/home/macma/.local/bin/uv' not found. [Line 2] CarinaStudio.AppSuite.Scripting.ScriptException: Command '/home/macma/.local/bin/uv' not found.
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]:  ---> System.InvalidOperationException: Command '/home/macma/.local/bin/uv' not found.
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]:    at CarinaStudio.AppSuite.Scripting.Application.PrepareExecutingCommand(String command, CancellationToken cancellationToken)
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]:    at CarinaStudio.AppSuite.Scripting.Application.ExecuteCommand(String command, Action`2 action, CancellationToken cancellationToken)
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]:    at Submission#0.<<Initialize>>d__0.MoveNext() in :line 27
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]:    --- End of inner exception stack trace ---
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]:    at CarinaStudio.AppSuite.Scripting.RoslynBasedScript.RunCore(IContext, CancellationToken)
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]:    at CarinaStudio.AppSuite.Scripting.BaseScript.<>c__DisplayClass52_0`1.<RunCoreEntry>b__1()
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]:    at System.Threading.Tasks.Task`1.InnerInvoke()
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]:    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]: --- End of stack trace from previous location ---
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]:    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
2025-08-15 13:29:21.7433 22344    10 ERROR Script[CooperativeLogAnalysisScriptSet]:    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
2025-08-15 13:29:21.7433 22344     1  WARN App: Perform GC with mode Optimized
2025-08-15 13:29:21.7600 22344    11 ERROR ScriptDisplayableLogAnalyzer: Error occurred while running analysis script of 'Cooperative log analysis' (lz231rd9): [Line:2] Command '/home/macma/.local/bin/uv' not found.

Analysis script:

/*
 * Types are imported automatically for log analysis. For ex, ILog and ResultType.
 * Please refer to https://carinastudio.azurewebsites.net/Scripting
 * and https://carinastudio.azurewebsites.net/ULogViewer/LogAnalysis#LogAnalysisScript for more information.
 */
using System.Text.RegularExpressions;

//  ZIGBEE RX:  (60 bytes) 0x7E0038900013A...
var msg = Context.Log.GetProperty<string>("Message");
string pattern = @"ZIGBEE RX:\s*\(\d+\sbytes\)\s*0x(?<hex_str>[\dA-Fa-f]+)";

var match = Regex.Match(msg, pattern); 
if (match.Success)
{
    var hex_str = match.Groups["hex_str"];
    string decoded = "";
    //var cmd = "/home/macma/.local/bin/uv";
    //var cmd = $"/home/macma/.local/bin/sm1 decode {hex_str}";
    
    var cmd_full = App.FindCommandPath("uv");
    LogInfo($"cmd_full: {cmd_full}");
    App.ExecuteCommand(cmd_full, (process, cancellationToken) =>
    {
        
        var reader = process.StandardOutput;
        decoded = reader.ReadToEnd();
    });
    Context.AddResult(new Result()
    {
        Log = Context.Log,
        
        Message = $"Decoded: {decoded}",
        Type = ResultType.Information,
    });
    return true;

}
/*
 * Return True to take results added by Context.AddResult(), or False to ignore current log and results.
 */
return false;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions