This is not possible without invoking the shell. However, two kuldges are available:
1) You can create a function in an unsafe language (e.g. python) in postgresql, which then runs pgsql2shp. This is an ugly hack, but has the advantage of creating a shapefile by SQL query.
2) sql , ST_AsText. csv sql COPY TO, csv , script.
( 2, , ), .