Command Line Access


#1

Okay, so most of the wiki dreamhost tutorials on how to do something, require that you enter stuff into command line.

But I can’t find any where to enter the command line stuff into. Where can I find that?

In my case, I want to use SQLite… but I think I need to install it first…

When I go to:

Almost the entire thing has to do with this mythical command line, that I can’t find any access to.

Below is what i’ve tried doing to create a sqlite database, but I keep getting fatal errors.

[php]

<?php if ($db = sqlite3::open('mysqlitedb', 0666, $sqliteerror)) { sqlite_query($db, 'CREATE TABLE foo (bar varchar(10))'); sqlite_query($db, "INSERT INTO foo VALUES ('fnord')"); $result = sqlite_query($db, 'select bar from foo'); var_dump(sqlite_fetch_array($result)); } else { die($sqliteerror); } ?>

[/php]

If someone could help me install or get sqlite running that would be great!


#2

The problem with your code is that you’re mixing up the SQLite (2.x) and SQLite3 APIs. Either change “sqlite3::open” to “sqlite_open” to use SQLite 2.x, or change “sqlite_query” and “sqlite_fetch_array” to “$db->query” and “$result->fetcharray” to use SQLite3. Of the two, SQLite3 is preferred, as SQLite 2.x is outdated and is no longer supported under some newer versions of PHP.

To get to the DreamHost command line, you will need to log in using SSH. Most of the information you’ll need to know is explained at: http://wiki.dreamhost.com/SSH


#3

Thanks for the quick reply!

I changed my code to:

[php]

<?php if ($db = sqlite3::open('mydb', 0666, $sqliteerror)) { $db->query('CREATE TABLE foo (bar varchar(10))'); $db->query("INSERT INTO foo VALUES ('fnord')"); $result = $db->query('select bar from foo'); var_dump($result->fetcharray($result)); } else { die($sqliteerror); } ?>

[/php]

And I get this:

[hr]
Also when I try to ssh into my machine… I get this message:

NEW UPDATE: nvm, I got in ssh, I just needed to create a user that had SSH abilities.


#4

Oh, right. Correct syntax on the first bit would be:

[php]
$db = new SQLite3(“mydb”);
[/php]

Ignore SQLite3::open(), as well as the extra arguments you were passing.


#5

careful there, you might want to edit your original user to allow SSH, creating a new one won’t connect it to the same files.


#6

Yup, just figured that out…