I am trying to refresh a tableau extract remotely from a linux box using the command :
./tableau_script.bash refreshextracts --server servername --username username --Password password --project <project name with spaces> --workbook <workbook with spaces>
tableau_script.bash is a bash script with the java call to tabcmd class.
The issue I face is with the spaces in the workbook or project ,could not find any way to escape this ,tried \,%20,%%20 but none seems to work.
Any suggestions.
Enclose project name with this "\"
You simply need to escape the spaces.
./tableau_script.bash refreshextracts --server servername --username username --Password password --project project\ name\ with\ spaces --workbook workbook\ with\ spaces
Related
I am using postgres 9.3 . I want to make a script to create my database cluster and supply the password inline in the terminal. I know you can do it from file, but is there a way to do it command line?
that is the line I am using right now : 'initdb -D path/to/cluster -W -A password'
it then prompt me for password, I tried to provide it inline, but it does not work. Any ideas?
thanks
You can accomplish this with a shell trick. Assuming bash shell:
initdb -D path/to/cluster -A password --pwfile=<(echo secretpassword)
(Although you should never use -A password, use at least md5.)
As for your comment, it is hard to say what is going on. You don't show us starting the server at all, or setting the port to start on to 5555, nor creating a user named 'dbuser'.
thanks everyone!
It worked when I changed 'password' to 'md5' in my initdb statement.
although in the password.txt file, I can only store the password. If I follow the documentation from postgres
host:port:username:password it does not work anymore
I solved the connection problem with .pgpass. I've created the .pgpass file in the home directory and I was able to connect using: "psql -U username -d database -pXXXX"
Ok, my initial question was to supply the password inline in the terminal. But ,the proper way of doing is using the password file for security reason. Second, in the initdb statement use at least md5 for encryption. The password will be for the superuser for the default database. You statement should look like this:
"initdb -D /path/to/dbCluster -A md5 --pwfile=/path/to/password.txt"
Now, if you want to automatically connect to the database with psql without password prompt, you have to create a .pgpass file (linux) or pgpass.conf file (windows) with your user and password info in this format: host:port:db_name:user_name:password
Where you put those file is important:
Windows : /Users/user_name/AppData/Roaming/postgresql/pgpass.conf
(If the postgresql folder does not exist, you have to create it)
Linux : /home/user/.pgpass (with chmod 0600 permission on the file)
How to force psql to detect .pgpass file on Windows 10 system?
As I'm sure you will be aware after reading this question, I'm brand new to PowerShell.
I want to back up a PostgreSQL database every day automatically using the Windows task scheduler. The backup file needs to include the current date. I created a file named db_backup.bat and run it within the Task Scheduler. Here it is, broken into several lines for readability:
"C:/Program Files (x86)/PostgreSQL/9.3/bin\pg_dump.exe"
--host localhost --port 5432 --username "postgres"
--no-password --format custom --verbose
--file "c:/misc/restore_test_%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%.backup" "Restore Test"
I hate the need to format the date like this. PowerShell has much cleaner ways to extract date information, so I'd like to do this from a PowerShell script.
So I created db_backup.ps1, containing this:
"C:/Program Files (x86)/PostgreSQL/9.3/bin/pg_dump.exe" --host localhost --port 5432
--username postgres --no-password --format custom --verbose
--file "c:/misc/restore_test.backup" "Restore Test" >> c:/misc/restore.txt
When I run this from Powershell, I get an error complaining about an unexpected token named --host. PS thinks "host" is a parameter for PowerShell, but it's supposed to be a parameter for the pg_dump program.
I tried wrapping all of the pg_dump parameters into a single string, but then PS thinks the entire string is a parameter for itself instead of passing it as a parameter to pg_dump.
So, how do I send command-line parameters to pg_dump?
I'm trying to run the az sql db export command and it requires a SQL Admin username and password. Our password happens to have two dollar signs in it e.g. ABC$$123==). So when I run the following command (with valid values in it, of course):
$pwd = "ABC$$123==)"
az sql db export -s myserver -n mydatabase -g mygroup -p $pwd-u login \
--storage-key MYKEY== --storage-key-type StorageAccessKey \
--storage-uri https://myAccountName.blob.core.windows.net/myContainer/myBacpac.bacpac
I get this response:
')' is not recognized as an internal or external command,
operable program or batch file.
I've tried so many variations of escaping this but haven't found the correct method that works. In the end, I plan to read the password from Azure Key Vault and was gonna pass it straight in to the az cli command. What do I have to do to get this to work?
There are two types of quotes in powershell - single and double. In the double quote, you can pass in variables. In a single quote, everything is literal. For cases like your password, I would recommend just using the literal:
$pwd = 'ABC$$123==)'
I'm trying to log in to Google's Container Registry on Windows 10 by using a JSON Key file. I have this working without issues on my Mac so the keyfile is definitely working.
First off I had issues getting the docker login function to accept the contents of the JSON key file. I've tried running the "/set /p PASS..." command in CMD and I've tried something along the lines of this in Powershell:
docker login -u _json_key -p "$(Get-Content keyfile.json)" https://gcr.io
These all result in either an error or this:
"docker login" requires at most 1 argument.
Since I couldn't get this to work, I ran:
docker login -u _json_key https://gcr.io
And then just removed all breaks from the JSON file manually, copied it to clipboard and pasted it when prompted for my password.
That results in:
Login Succeeded
Problem solved! Right?
Well apparently not. I was still unable to pull my images and when I ran docker info the only registry listed was "https://index.docker.io/v1/".
I've tried starting Powershell as admin, and restarted and reset docker but nothing seems to help.
Anyone got any clue what is going on? How do I debug this?
I'm running Docker version 17.12.0 (stable)
I found a solution that works for both Windows (in PowerShell) and bash. The secret is to use the "provide a password using stdin".
cat gcr_registry-ro.json | docker login -u _json_key --password-stdin https://gcr.io
Login Succeeded
Help text and versions:
PS C:\Users\andy> docker login --help
Usage: docker login [OPTIONS] [SERVER]
Log in to a Docker registry
Options:
-p, --password string Password
--password-stdin Take the password from stdin
-u, --username string Username
PS C:\Users\andy> docker -v
Docker version 18.06.1-ce, build e68fc7a
PS C:\Users\andy>
In PowerShell:
(Get-Content keyfile.json) | docker login -u _json_key --password-stdin https://gcr.io
I got it working now by using the trick I did with removing all line breaks in the key, copying it and then pasting it when I'm prompted for my password, instead of trying to pass it into the -p parameter.
Turns out I had to change the url to eu.gcr.io instead of just gcr.io.
I wrote some feedback on the GCR documentation page - Hopefully they'll fix it and maybe even add the correct way to do it in Powershell.
Only thing I'm still wondering is why I can't see that I'm logged into GCR in docker info.
DB: PostgreSQL 9.0
Client: Windows 7
Server Windows 2008, 64bit
I'm trying to connect remotely to a PostgreSQL instance for purposes of performing a pg_dump to my local machine.
Everything works from my client machine, except that I need to provide a password at the password prompt, and I'd ultimately like to batch this with a script.
I've followed the instructions here:
http://www.postgresql.org/docs/current/static/libpq-pgpass.html
But it's not working.
To recap, I've created a file on the server: C:/Users/postgres/AppData/postgresql/pgpass.conf, where PostgreSQL is the db user.
The file has one line with the following data:
\*:5432:\*postgres:[mypassword]
I've also tried replacing each * with [localhost|myip] and [mydatabasename] respectively.
From my client machine, I connect using:
pg_dump -h <myip> -U postgres -w [mydbname] > [mylocaldumpfile]
I'm presuming that I need to provide the -w switch in order to ignore password prompt, at which point it should look in the AppData directory on the server.
It just comes back with:
connection to database failed: fe_sendauth: no password supplied.
As a hack workaround, if there was a way I could tell the Windows batch file on my client machine to inject the password at the PostgreSQL prompt, that would work as well.
It works for me:
Use command line
cd %appdata%
mkdir postgresql
cd postgresql
notepad pgpass.conf
inside pgpass.conf paste your connection string (*:5432:*postgres:[mypassword]) and save the file.
To connect to postgres use:
psql/pg_dump -U <username> -h <host> -w <other params you want to use>
I have solved similar problem (only in Linux) to use ip address in pgpass and psql.
.pgpass
127.0.0.1:5432:db:dbuser:123
psql params
psql -d db -U dbuser -h 127.0.0.1 -w
pg_hba conf with default settings:
# IPv4 local connections:
84 host all all 127.0.0.1/32 md5
Create pgpass.conf file
Windows > Start > Run
type %APPDATA%
press OK
Create a folder: postgresql
Create a file : pgpass.conf (under postgresql folder)
Open pgpass.conf file
Now you should have below file ready, open it via below (making sure it exists):
Windows > Start > Run
type %APPDATA%\postgresql\pgpass.conf
press OK
Paste pgpass.conf file contents
Paste the below
# serverDomainOrIP:PORT:databaseName:userName:password
# 127.0.0.1:5432:myDbName:postgres:myPassword
# *:5432:*:*:myPassword
You can do one of the below:
- Remove # for the 3rd line, and give your password in the place of "myPassword"
OR
- Remove # for the 2nd line, and give ip (or, yourDomain.com), dbname, username & password
Hope that helps.
I've had a similar problem which I didn't manage to resolve - I couldn't get the script to recognise the pgpass.conf file. I however used a work-around of setting the PGPASSWORD environment variable in the batch file I was using (PostgreSQL 9.6).
Inside a batch file:
SET PGPASSWORD=<<password>>
pg_dump.exe -h <<host>> -p <<port>> -U <<user>> -Fc -b -v -f <<output file path>> <<database>>
I have gotten it to work with the following:
pgpass.conf:
127.0.0.1:5432:*:username:password
However, I have it stored here:
C:\Users\<user>\AppData\Roaming\postgresql
For some reason, on a previous iteration of Postgres, the database had generated the pgpass file and stored it there. I was running into the same issue you were having, moved it to that directory and it worked. I'm not sure why though.
Then, all you'll need to do is:
pg_dump -h myip mydb > mylocaldumpfile
...ensuring that myip and the ip in pgpass.conf are identical. If they are not, it will prompt you for a password.
You could use pgAdmin III to store the password (in the server's properties).
That operation automatically creates a correct pgpass.conf file. You can then schedule a task to run a simple batch file that would read:
"C:\path\to\pg_dump.exe" -U <user> -w <database> > C:\path\to\database.backup
Make sure you are logged in as the user corresponding with the folder where the pgpass.conf file lives.
If you are using UTF-8 encoding, please ensure that you are using without BOM mode.
Otherwise leave the first line as a comment:
# This line may contain hidden BOM bytes
localhost:5432:database:username:password
Also you don't need to escape asterisks \*, just put * to enable wildcard matching.