Hello all whenever error happens while executing t...
# general
h
Hello all whenever error happens while executing the script I want this piece of code to run createFolderAndFile.stderr.apply((error) => { if (error) { console.log("Error:", error); } }); but it seems to be not running
Copy code
const setupScript2 = `
#!/bin/bash

non_existent_command
`;

let createFolderAndFile = new command.remote.Command("createFolderAndFile", {
  connection: {
    host: "XX.XX.XX.XX",
    user: "root",
    password: "XXXXXXXXX", // Replace with your actual password
  },
  create: setupScript2,
});

createFolderAndFile.stdout.apply((output) => {
  console.log("Output:", output);
});

createFolderAndFile.stderr.apply((error) => {
  if (error) {
    console.log("Error:", error);
  }
});

export const error = createFolderAndFile.stderr;
export const output = createFolderAndFile.stdout;
My terminal after I run pulumi up
Copy code
pulumi up
Previewing update (dev)

View in Browser (Ctrl+O): <https://app.pulumi.com/|https://app.pulumi.com/>..........................................

     Type                       Name                     Plan
 +   pulumi:pulumi:Stack        create_folder_files-dev  create
 +   └─ command:remote:Command  createFolderAndFile      create
Outputs:
    error : output<string>
    output: output<string>

Resources:
    + 2 to create

Do you want to perform this update? yes
Updating (dev)

View in Browser (Ctrl+O): <https://app.pulumi.com/|https://app.pulumi.com/>............................................

     Type                       Name                     Status                  Info
 +   pulumi:pulumi:Stack        create_folder_files-dev  **creating failed**     1 error
 +   └─ command:remote:Command  createFolderAndFile      **creating failed**     1 error
Diagnostics:
  pulumi:pulumi:Stack (create_folder_files-dev):
    error: update failed

  command:remote:Command (createFolderAndFile):
    error: Process exited with status 127: running "\n#!/bin/bash\n\nnon_existent_command\n":
    bash: line 3: non_existent_command: command not found

Resources:
    + 1 created

Duration: 8s
f
This looks pretty logged to me:
Copy code
command:remote:Command (createFolderAndFile):
    error: Process exited with status 127: running "\n#!/bin/bash\n\nnon_existent_command\n":
    bash: line 3: non_existent_command: command not found
h
My bad sorry, when error happens while executing the script I want this piece of code to run createFolderAndFile.stderr.apply((error) => { if (error) { console.log("Error:", error); } });
f
Hmm, that's a tough one - it looks like pulumi is catching the bash return code and triggering a failure before it gets to the part of your code where you call
.apply
on the stderr string. In a sense, pulumi doesn't want to run
Command.stderr.apply
because it considers the command to have failed - I'm not sure how to fix this