pipeProcess output to hash string
user1234
user1234 at 12.de
Sat Sep 9 16:49:30 UTC 2023
On Saturday, 9 September 2023 at 15:44:44 UTC, Vino wrote:
> Hi All,
>
> Request your help on how to convert the output of
> std.process.pipeProcess to hash string
>
> ```
> auto test(in Redirect redirect=Redirect.stdout |
> Redirect.stderr) {
> import std.process;
> import std.digest.crc;
> import std.stdio: writeln;
>
> result = std.process.pipeProcess("whoami" ~ "/?",
> redirect);
> auto content = result.stdout.readln;
> auto hash = crc32Of(content);
> return hash;
> }
> void main() {
> writeln(test);
> }
> ```
>
> Output: All writes the below.
> ```
> [0, 0, 0, 0]
> ```
>
> Required: Read the completed output and convert it to a single
> hash string.
>
> From,
> Vino.B
With a slightly modified command line that works on linux here :
```d
import std.process, std.stdio;
auto test(in Redirect redirect=Redirect.stdout | Redirect.stderr)
{
import std.digest.crc;
import std.stdio: writeln;
auto result = std.process.pipeProcess(["whoami"], redirect);
auto content = result.stdout.readln;
auto hash = crc32Of(content);
return hash;
}
void main() {
writeln(test);
}
```
not sure why you append "/?" to the program name.
More information about the Digitalmars-d-learn
mailing list