Page 1 of 1

.net core running vesta cli script

Posted: Thu Jun 25, 2020 1:30 pm
by orgolan
hello readers,

i've built .net core website on ubuntu machine.

i have a method for executing bash commands:

Code: Select all

public static string Bash(string cmd)
{
    var escapedArgs = cmd.Replace("\"", "\\\"");

    var process = new Process()
    {
        StartInfo = new ProcessStartInfo
        {
            FileName = "/bin/bash",
            Arguments = $"-c \"{escapedArgs}\"",
            RedirectStandardOutput = true,
            UseShellExecute = false,
            CreateNoWindow = true,
        }
    };
    process.Start();
    string result = process.StandardOutput.ReadToEnd();
    process.WaitForExit();
    return result;
}

example call would be:

Code: Select all

 Bash("/home/admin/test.sh");
the test.sh content:

Code: Select all

#! /bin/bash
sudo /usr/local/vesta/bin/v-add-user testuser testpass me@gmail.com basic
when the code executing i'm catching bash errors and part of them are:

Code: Select all

/usr/local/vesta/bin/v-add-user: line 21: /func/main.sh: No such file or directory
/usr/local/vesta/bin/v-add-user: line 22: /conf/vesta.conf: No such file or directory
/usr/local/vesta/bin/v-add-user: line 36: check_args: command not found
/usr/local/vesta/bin/v-add-user: line 37: is_format_valid: command not found
/usr/local/vesta/bin/v-add-user: line 42: is_password_valid: command not found
/usr/local/vesta/bin/v-add-user: line 43: is_package_valid: command not found
how do i solve this?
is it something with dotnet not declared in path thing?
is it shebang line thing?
please help