I am working on pressly/goose tool for migration.
All my commands run from shell script file inside docker container. I wanted to hide certain command or password from the console output logs.
Here is the command,
goose postgres "user=postgres password=postgres dbname=postgres sslmode=disable" status
I have tried stty -echo | command | stty echo this also.
Is there any way to hide command/password and only shows the output of that command?
Related
I am trying to execute below unix script to fetch the oracle version from windows command prompt using ssh command to connect to unix terminal
#!/usr/bin/ksh
Freport=/tmp/test.txt
cd /usr/oracle2/product/11.2.0/bin
echo "Begin" > $Freport
set +x
/usr/oracle2/product/11.2.0/bin/sqlplus -V >> $Freport
set -x
pwd >> $Freport
echo "Completed" >> $Freport
Windows command prompt output
Begin
/usr/oracle2/product/11.2.0/bin
Completed
Same script ran in unix server and got below output
Putty output
Begin
SQL*Plus: Release 11.2.0.1.0
/usr/oracle2/product/11.2.0/bin
Completed
I want to print the oracle version in my windows command prompt output. Kindly help me to resolve it
Windows cmd prompt execution
C:\programfiles\PUTTY>putty.exe -ssh uname#ip -pw pwd -m windowsscriptpath/test.sh
Can someone please help me with this? I got struck here.. Is there any option to execute the unix server script directly from windows since shell script is working fine in unix server –
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.
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/
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.
I'm a newbie at this. I want to write a script that I can execute from command line to run a query on a Heroku-hosted PostgreSQL database.
Right I have a script script.sh with executable permissions that looks like:
echo "Starting pull from postgres ..."
heroku pg:psql <db> --app <app-name>
\copy (<query>) to 'file.csv' WITH CSV
\q
echo "Done!"
The echo and heroku ... commands runs fine, however, once Heroku launches, the script no longer injects the commands. Only after I manually close out the Heroku app does it inject the last three lines.
I understand that this is a bash script that isn't intended to input postgreSQL commands once Heroku is open, but is there a way to do this?
I get the sense that it might involve connecting to Heroku and submitting the query in one line -- I searched around Heroku's documentation but didn't see anything that would be helpful.
You can use the --command flag to pass SQL commands to heroku pg:psql along with the server-based COPY and then redirect the output to a file:
echo "Starting pull from postgres ..."
heroku pg:psql <db> --app <app-name> --command "COPY (<query>) TO STDOUT WITH CSV" > file.csv
echo "Done!"
I just freshly installed SQL Server Express 2014 via Chocolatey. The service is currently running.
When I run this inside my CMD or Powershell:
> sqlcmd -e -S .\SQLEXPRESS
1> sp_databases;
2>
I get no output, it just goes to the next prompt line.
However when I use this style, I do get output:
> sqlcmd -e -S .\SQLEXPRESS -Q "sp_databases;"
sp_databases;
DATABASE_NAME DATABASE_SIZE REMARKS
-------------------------------------------------------------------------------------------------------------------------------- ------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
master 7808 NULL
model 5312 NULL
msdb 37632 NULL
tempdb 2560 NULL
What could be the reason for this? I have no special configuration for the CMD or Powershell except some colour changes of the console.
Turns out I just needed to run GO at the end of each command. Silly.
I am trying to restore the postgres sql data from a file . I am trying to do so but it is not importing .
Here is the command which i am using:
postgres-# psql -hlocalhost -p5432 -u postgres -d test -f C:/wamp/www/test/database_backups/backup004.sql
Please help me what I am doing wrong .
I am using windows and the above command does not throws any error but it does not import data.
Regards
Surjan
The only immediate thing I can see there is the capitilsation of -u for username (should be -U).
Correction: You're typing the command line into the psql shell.
You should exit to the CMD.EXE shell, and try the command there. With the correct capitalisation of -U, by the way.
OR, use this to replay the script into that psql shell:
\i C:/wamp/www/test/database_backups/backup004.sql
The forward slashes don't cause a problem on my Windows machine.