I want to be able to run a shell command like this from within a stored procedure. Is there a way to do this ?
In core, you can probably use the untrusted version of Perl, Python, or Tcl to accomplish your goal. SQL and pl/pgSQL do not provide that capability.