0

On RHEL, the below command works: psql -h hostname -U username -p port_no -d database -f /tmp/myfile.sql &> logfile01.txt

On FreeBSD, this throws error: "Invalid null command"

Please suggest.

pricha
  • 65
  • 1
  • 11

2 Answers2

1

If you use this only on the command line then there is no need to change the shell. To redirect stdout and stderr to a file in C-Shell synthax simply use ">& filename".

Different story is, if you want to write shell scripts. Bourne Shell and it's clones (like i.e. Bash) are better suited for writing script. See this Unix FAQ "Csh Programming Considered Harmful": http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

ennox
  • 206
  • 1
  • 5
0

This redirection works in bash

&> logfile01.txt

, but it does not work in csh which is the default shell in FreeBSD.

# set | grep shell
shell   /bin/csh
# ls -la &> logfile01.txt
Invalid null command.

Bash is not installed by default. You can install it

pkg install bash

and configure it as the default shell.

Vladimir Botka
  • 58,131
  • 4
  • 32
  • 63