# Stuck at #ni6: cat: /tmp/foo/f85: No such file or directory

**URL:** <https://forum.codecrafters.io/t/stuck-at-ni6-cat-tmp-foo-f85-no-such-file-or-directory/4709>\
**Category:** Challenges\
**Tags:** challenge:shell\
**Created:** [February 7, 2025, 6:04am UTC](https://forum.codecrafters.io/t/stuck-at-ni6-cat-tmp-foo-f85-no-such-file-or-directory/4709 "2025-02-07T06:04:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![anoopksurendran1112](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/anoopksurendran1112/32/4729_2.png) [@anoopksurendran1112](https://forum.codecrafters.io/u/anoopksurendran1112)\
**Post date:** [February 7, 2025, 6:04am UTC](https://forum.codecrafters.io/t/stuck-at-ni6-cat-tmp-foo-f85-no-such-file-or-directory/4709/1 "2025-02-07T06:04:49Z")

</div>

I’m doing the Build your own shell using javascript and stuck at #ni6. I have managed to implement the single quote issue in echo command. But i can’t figure out the cat command.  
I think the task is to make

> cat ‘/tmp/quz/f 46’ ‘/tmp/quz/f 14’ ‘/tmp/quz/f 3’

into

> cat ‘/tmp/quz/f46’ ‘/tmp/quz/f14’ ‘/tmp/quz/f3’ ]

and execute.  
I tried to execute the cat command through the node child-process execFileSync() method. It shows No such file or directory

Here are my logs:

 ![ni6](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/f/ffd433a2078ad8f9b23398b6e2b0b60fac37013e.png)

And here’s a snippet of my code:

 ![ni6-code](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/8/86a11fd11c075aa79b2b989c05c15c9bb6d6f894.png)

---

<div class="post-metadata">

**Author:** ![Jh123x](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/jh123x/32/4615_2.png) [@Jh123x](https://forum.codecrafters.io/u/Jh123x)\
**Post date:** [February 7, 2025, 2:44pm UTC](https://forum.codecrafters.io/t/stuck-at-ni6-cat-tmp-foo-f85-no-such-file-or-directory/4709/3 "2025-02-07T14:44:05Z")

</div>

For the cat command, it is a binary available at

```auto
/usr/bin/cat

```

I don’t think you have to implement your own cat command

---

<div class="post-metadata">

**Author:** ![anoopksurendran1112](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/anoopksurendran1112/32/4729_2.png) [@anoopksurendran1112](https://forum.codecrafters.io/u/anoopksurendran1112)\
**Post date:** [February 7, 2025, 3:15pm UTC](https://forum.codecrafters.io/t/stuck-at-ni6-cat-tmp-foo-f85-no-such-file-or-directory/4709/4 "2025-02-07T15:15:53Z")

</div>

How should i approach it, can you be more specific.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [February 7, 2025, 3:47pm UTC](https://forum.codecrafters.io/t/stuck-at-ni6-cat-tmp-foo-f85-no-such-file-or-directory/4709/5 "2025-02-07T15:47:19Z")

</div>

Hi @anoopksurendran1112, you can reuse the logic implemented in [#ip1 Run a program](https://app.codecrafters.io/courses/shell/stages/ip1?repo=aee8a11f-0fde-457c-8449-b778f43d6f80). Let me know if you need further clarification.

---

<div class="post-metadata">

**Author:** ![anoopksurendran1112](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/anoopksurendran1112/32/4729_2.png) [@anoopksurendran1112](https://forum.codecrafters.io/u/anoopksurendran1112)\
**Post date:** [February 8, 2025, 6:36am UTC](https://forum.codecrafters.io/t/stuck-at-ni6-cat-tmp-foo-f85-no-such-file-or-directory/4709/7 "2025-02-08T06:36:49Z")

</div>

This is the code i come up with for #ip1 run a program.

```auto
function programRun(answer){
  const fileName = answer.split(" ")[0];
  const argument = answer.split(" ").slice(1);
  const pathEnv = process.env.PATH;
  let found = false;
  const pathDir = pathEnv.split(":");
  for (const filepath of pathDir){
    const fullPath = path.join(filepath,fileName);
    if(fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()){
      execFileSync(fileName, argument, { encoding: 'utf-8', stdio: 'inherit' })
      found = true;
      break;
    }
  }
  if(found == false){
    console.log(answer+": command not found");
  }
}

```

I tried to use the filepath given in the cat command as the fileName in the execFileSync, and it didnt work

```auto
function catCommand(answer){
  let arg = answer.split("cat ")[1]
  arg = arg.match(/'([^']+)'/g).map(path => path.slice(1, -1));
  const filepaths = arg.map(path => path.replace(/\s+/g, ""));
  filepaths.forEach(files => {
    execFileSync(files, [], { encoding: 'utf-8', stdio: 'inherit' })
  });
}

```

It shows:

```auto
[your-program] $ cat '/tmp/baz/f 64' '/tmp/baz/f 88' '/tmp/baz/f 10'
[your-program] node:internal/readline/emitKeypressEvents:74
[tester::#NI6] Output does not match expected value.
[tester::#NI6] Expected: "blueberry mango.mango blueberry.strawberry pear."
[tester::#NI6] Received: "node:internal/readline/emitKeypressEvents:74"
[your-program] throw err;
[your-program] ^
[your-program] <ref *1> Error: spawnSync /tmp/baz/f64 ENOENT

```

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [September 25, 2025, 6:24am UTC](https://forum.codecrafters.io/t/stuck-at-ni6-cat-tmp-foo-f85-no-such-file-or-directory/4709/12 "2025-09-25T06:24:47Z")

</div>

@anoopksurendran1112 If you’re still running into issues, could you [upload your code to GitHub](https://docs.codecrafters.io/features/publish-to-github) and share the link? It will be much easier to debug if I can run it directly.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [October 1, 2025, 7:28am UTC](https://forum.codecrafters.io/t/stuck-at-ni6-cat-tmp-foo-f85-no-such-file-or-directory/4709/14 "2025-10-01T07:28:12Z")

</div>

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [October 6, 2025, 7:28am UTC](https://forum.codecrafters.io/t/stuck-at-ni6-cat-tmp-foo-f85-no-such-file-or-directory/4709/15 "2025-10-06T07:28:28Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
