# Install ports from PHP-Shell (portsnap fetch should not be run non-interactively.)



## Malcom (Mar 9, 2013)

Hey there,

I am using a PHP-Script to install ports.


```
$ssh->exec("portsnap fetch extract")
```

But it still gives me this error.

```
Result: portsnap fetch should not be run non-interactively. Run portsnap cron instead.
```

Is there another way to do this via php? [cmd=]portsnap cron[/cmd] is not a solution for me).


----------



## Carpetsmoker (Mar 11, 2013)

/usr/bin/portsnap is just a shell script, sh's manpage says:

```
-i interactive
             Force the shell to behave interactively.
```

Note there's probably a good reason you're getting this error. I don't use portsnap, so I don't know why, I just tested it, and it doesn't *seem* interactive ...


----------



## kpa (Mar 12, 2013)

The reason is that if run from cron(8), `# portsnap cron` should be used instead of `# portsnap fetch` to avoid hammering the portsnap(8) server at the exact hour, usually 3 AM. This is done by waiting a random amount of time before actually making the connection.


----------

