# Allow piping to stdin with runShellScript

**URL:** <https://community.folivora.ai/t/allow-piping-to-stdin-with-runshellscript/43656>\
**Category:** Feature Requests\
**Tags:** action, trigger, real-javascript, shell\
**Created:** [May 16, 2025, 5:22pm UTC](https://community.folivora.ai/t/allow-piping-to-stdin-with-runshellscript/43656 "2025-05-16T17:22:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Norpyx](https://community.folivora.ai/user_avatar/community.folivora.ai/norpyx/32/39167_2.png) [@Norpyx](https://community.folivora.ai/u/Norpyx)\
**Post date:** [May 16, 2025, 5:22pm UTC](https://community.folivora.ai/t/allow-piping-to-stdin-with-runshellscript/43656/1 "2025-05-16T17:22:11Z")

</div>

Setting Environment Variables is great, but it has it's limitations.

When passing complex data to a script, for instance, escaping becomes cumbersome and difficult. For instance, for a string with a semi-colon ";", there's always some finagling that has to happen in order to make sure that the semi-colon is serialized and then deserialized to prevent things from breaking.

But if we had the ability to use `stdin`, it would enable us to send more complex data to a target script:

```auto
let shellScriptWrapper = {
    script: "/absolute/path/to/my_script.js",
    launchPath: '/bin/bash',
    parameters: '-c',
    stdin: JSON.stringify(someObj)
};

let result = await runShellScript(shellScriptWrapper);

```

With a script like:

```auto
// my_script.js
(async () => {
  let chunks = [];
  for await (let chunk of process.stdin) {
    chunks.push(chunk);
  }
  const raw = chunks.join('');
  try {
    const obj = JSON.parse(raw);
    console.log(obj);
  } catch (err) {
    console.error('Invalid JSON:', err.message);
    process.exit(1);
  }
})();

```
