Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions challenges/linux-luminarium/chaining/script-pipe/DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ There are a few ways to do this, and we'll explore a simple one here: redirectin

As far as the shell is concerned, your script is just another command.
That means you can redirect its input and output just like you did for commands in the [Piping](/linux-luminarium/piping) module!
For example, you can write it to a file:

For example, you can pipe the output of your script into another command:

```console
hacker@dojo:~$ cat script.sh
#!/bin/bash
echo PWN
echo COLLEGE
hacker@dojo:~$ bash script.sh > output
hacker@dojo:~$ cat output
hacker@dojo:~$ ./script.sh | cat

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add chmod before invoking ./script.sh in example

The new example runs ./script.sh | cat immediately after showing file contents, but it never shows setting the execute bit; in a normal workflow (cat > script.sh, editor save, etc.), script.sh is typically created without execute permissions, so this command fails with “Permission denied.” Because this level comes before “Executable Shell Scripts,” readers can follow the snippet exactly and still fail; please either add chmod +x script.sh in the example or use bash script.sh | cat for a runnable demonstration.

Useful? React with 👍 / 👎.

PWN
COLLEGE
hacker@dojo:~$
```

All of the various redirection methods work: `>` for stdout, `2>` for stderr, `<` for stdin, `>>` and `2>>` for append-mode redirection, `>&` for redirecting to other file descriptors, and `|` for piping to another command.

In this level, we will practice piping (`|`) from your script to another program.
Like before, you need to create a script that calls the `/challenge/pwn` command followed by the `/challenge/college` command, and pipe the output of the script into a single invocation of the `/challenge/solve` command!
In this level, we will practice piping (`|`) the output from your executable script into another program. Specifically, create an executable script that calls `/challenge/pwn` followed by `/challenge/college`, and pipe the output of your script into a single invocation of `/challenge/solve`!