Could you please give me some hints to overcome the problem?
§§--> And this is what appears on the screen when I enter 'mydb':
usr@deby:~$ psql mydb Target width is 150. Output format is wrapped. psql (15.10 (Debian 15.10-0+deb12u1)) Type "help" for help.
You are executing the corresponding \pset commands for those two options in your .psqlrc file. For scripts you generally don't want to do that. Either modify your .psqlrc file, or pass -X to your psql command to ignore it.
Otherwise, those should be output on stdout; you can use your shell's tools to send it elsewhere so your output capture doesn't see it.