> ## Documentation Index
> Fetch the complete documentation index at: https://e2b-banner-hover-tooltip.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Template readycmd

### ReadyCmd

Class for ready check commands.

#### Constructors

```ts theme={null}
new ReadyCmd(cmd: string): ReadyCmd
```

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `cmd`     | `string` |

###### Returns

`ReadyCmd`

#### Methods

### getCmd()

```ts theme={null}
getCmd(): string
```

###### Returns

`string`

## Functions

### waitForFile()

```ts theme={null}
function waitForFile(filename: string): ReadyCmd
```

Wait for a file to exist.
Uses shell test command to check file existence.

#### Parameters

| Parameter  | Type     | Description                  |
| ---------- | -------- | ---------------------------- |
| `filename` | `string` | Path to the file to wait for |

#### Returns

`ReadyCmd`

ReadyCmd that checks for the file

#### Example

```ts theme={null}
import { Template, waitForFile } from 'e2b'

const template = Template()
  .fromBaseImage()
  .setStartCmd('./init.sh', waitForFile('/tmp/ready'))
```

***

### waitForPort()

```ts theme={null}
function waitForPort(port: number): ReadyCmd
```

Wait for a port to be listening.
Uses `ss` command to check if a port is open and listening.

#### Parameters

| Parameter | Type     | Description             |
| --------- | -------- | ----------------------- |
| `port`    | `number` | Port number to wait for |

#### Returns

`ReadyCmd`

ReadyCmd that checks for the port

#### Example

```ts theme={null}
import { Template, waitForPort } from 'e2b'

const template = Template()
  .fromPythonImage()
  .setStartCmd('python -m http.server 8000', waitForPort(8000))
```

***

### waitForProcess()

```ts theme={null}
function waitForProcess(processName: string): ReadyCmd
```

Wait for a process with a specific name to be running.
Uses `pgrep` to check if a process exists.

#### Parameters

| Parameter     | Type     | Description                     |
| ------------- | -------- | ------------------------------- |
| `processName` | `string` | Name of the process to wait for |

#### Returns

`ReadyCmd`

ReadyCmd that checks for the process

#### Example

```ts theme={null}
import { Template, waitForProcess } from 'e2b'

const template = Template()
  .fromBaseImage()
  .setStartCmd('./my-daemon', waitForProcess('my-daemon'))
```

***

### waitForTimeout()

```ts theme={null}
function waitForTimeout(timeout: number): ReadyCmd
```

Wait for a specified timeout before considering the sandbox ready.
Uses `sleep` command to wait for a fixed duration.

#### Parameters

| Parameter | Type     | Description                                               |
| --------- | -------- | --------------------------------------------------------- |
| `timeout` | `number` | Time to wait in milliseconds (minimum: 1000ms / 1 second) |

#### Returns

`ReadyCmd`

ReadyCmd that waits for the specified duration

#### Example

```ts theme={null}
import { Template, waitForTimeout } from 'e2b'

const template = Template()
  .fromNodeImage()
  .setStartCmd('npm start', waitForTimeout(5000)) // Wait 5 seconds
```

***

### waitForURL()

```ts theme={null}
function waitForURL(url: string, statusCode: number): ReadyCmd
```

Wait for a URL to return a specific HTTP status code.
Uses `curl` to make HTTP requests and check the response status.

#### Parameters

| Parameter    | Type     | Default value | Description                                                                         |
| ------------ | -------- | ------------- | ----------------------------------------------------------------------------------- |
| `url`        | `string` | `undefined`   | URL to check (e.g., '[http://localhost:3000/health](http://localhost:3000/health)') |
| `statusCode` | `number` | `200`         | Expected HTTP status code (default: 200)                                            |

#### Returns

`ReadyCmd`

ReadyCmd that checks the URL

#### Example

```ts theme={null}
import { Template, waitForURL } from 'e2b'

const template = Template()
  .fromNodeImage()
  .setStartCmd('npm start', waitForURL('http://localhost:3000/health'))
```
