5

Running Ubuntu 17.10 and I am having an issue running Postgres. It was working a couple weeks ago, but now I have this problem.

sudo su postgres psql

/usr/bin/psql: line 19: use: command not found
/usr/bin/psql: line 20: use: command not found
/usr/bin/psql: line 21: use: command not found
/usr/bin/psql: line 22: use: command not found
/usr/bin/psql: psql: line 24: syntax error near unexpected token `$version,'
/usr/bin/psql: psql: line 24: `my ($version, $cluster);'

I have no idea what to do, the syntax looks normal.

BillRobertson42
  • 12,602
  • 4
  • 40
  • 57
Oh Great One
  • 374
  • 2
  • 17
  • Is `/usr/bin/psql` a Perl script that starts with `#!/bin/sh` or similar? Line 24 suggests that it is Perl, line 19 suggests that it is Perl being fed to a shell. – mu is too short Mar 16 '18 at 18:34

1 Answers1

11

Try

sudo -u postgres psql

instead.

I actually do not know what your command does. A quick look to man su does not really clarify what su will do with extra arguments but obviously it is not starting psql, it is probably feeding the file contents to the shell.

markus987
  • 301
  • 3
  • 8
  • Thank you for your help and this is correct. I was using the other way because I had seen someone else using it to start postgres and I figured it was the correct way. (Bad assumption) – Oh Great One Mar 16 '18 at 20:14
  • sudo without the "-u" or plain "-" inherits your current environment. With the "-" it sets up a new environment as if you were logging in as the other user. – rotten Mar 18 '18 at 11:03