Powershell : Unexpected token '-l' in expression or statement - powershell

im trying to use the following command to convert files from one format to another using a tool, but powershell gives me an error:
"C:\Program Files\Java\jre1.8.0_361\java" -cp C:\Users\yporn\Desktop\work\travel40\public\doc\weka.jar weka.clusterers.SimpleKMeans -T C:\Users\yporn\Desktop\work\travel40\public\doc\unseen.arff -l C:\Users\yporn\Desktop\work\travel40\public\doc\Tourist.model
The error is
Unexpected token '-cp' in expression or statement.

Related

Can I pass a .sql file to psql?

I'm trying to pass a sql file to psql. After reading the docs, tried:
psql_args=(
"password='$INPUT_PASSWORD'"
dbname=analytics
"host='$INPUT_HOST'"
user=analytics
port=32648
file=query.sql
)
psql "${psql_args[*]}"
psql: error: invalid connection option "file"
root#380773cb4e26:/#
If I remove the file=query.sql arg this results in a connection to psql. I just don't know how to pass it a query file?
On the docs, two arguments look like ones of interest here:
-f filename
--file=filename
Read commands from the file filename, rather than standard input
and also:
-c command
--command=command
Specifies that psql is to execute the given command string, command
I tried the file=query.sql one but that failed with the error message above.The command one wants a string whereas I want to pass a .sql file. I tried anyway:
psql_args=(
"password='$INPUT_PASSWORD'"
dbname=analytics
"host='$INPUT_HOST'"
user=analytics
port=32648
command=query.sql
)
psql "${psql_args[*]}"
psql: error: invalid connection option "command"
Is there a way that I can pass query.sql to psql in order to run a query?
You seem to be packaging options up into a connection string. But --file must be given directly as an option to psql, not as part of a connection string.
psql "${psql_args[*]}" --file=query.sql
Since other answer seem to overlook this.
Here is how to store dynamic options into an array, and pass it as arguments to the command:
#!/usr/bin/env bash
psql_args=(
"--dbname=analytics"
"--host=$INPUT_HOST"
"--user=analytics"
"--port=32648"
"--file=query.sql"
)
psql "${psql_args[#]}"

psql command problem with // (double-slash)

/COPY MondayLotto FROM 'https://thelottoproject.blob.core.windows.net/data/MondayLotto.csv' DELIMITER ',' CSV HEADER
The command returns these error messages
(In Azure Cloud Shell terminal)
https:/thelottoproject.blob.core.windows.net/data/MondayLotto.csv: No such file or directory
(In SQL Shell (psql) on Windows10)
https:/thelottoproject.blob.core.windows.net/data/MondayLotto.csv: Invalid argument
I guess the // caused the error because the error message shows only / after https:
PostgreSQL server in Azure
The CSV file in Azure blob storage is accessible.
Is there any solution for this problem?
psql special commands starting by \ so the syntax should be
\copy MondayLotto FROM ...
Probably there will be second issue too. I don't know how the table MondayLotto was created. This looks like case sensitive identifier, and if it is really case sensitive identifier, then it should be used inside parentheses like "MondayLotto".
To load data from a web site, you could run something like
wget -O - https://thelottoproject.blob.core.windows.net/data/MondayLotto.csv | psql -c "COPY mondaylotto FROM STDIN (FORMAT 'csv', HEADER)"

jq reading filter from a file results in Invalid Syntax Error

filter.jq
".security = {hideVersionStringsWhenNotLogged: true}"
When trying to apply the filter,
jq --from-file filter.jq a.json
encountering the following error
jq: error: syntax error, unexpected INVALID_CHARACTER, expecting $end (Unix shell quoting issues?) at , line 1
tried all combinations of single and double quotes to no avail.
Any suggestions?
Thx
If you want the filter to be read from a file, do not enclose it in the quotation marks that are needed if the filter is specified on the command line.
So the contents of your filter.jq file could look like this:
.security = {hideVersionStringsWhenNotLogged: true}

Autorunsc64 (sysinternals) command line issue in PowerShell

I am trying to execute autorunsc64.exe (Sysinternals) in PowerShell like so:
"C:\Program Files (x86)\Autoruns\autorunsc64.exe" -a * > "C:\Program Files (x86)\Autoruns\output.txt"
However, it does not like single or double quotes anywhere. I've tried many variations but cannot seem to find the solution. I keep getting the following errors:
Unexpected token '-accepteula' in expression or statement
Unexpected token '-a' in expression or statement
If the paths do not have spaces, it works without issue:
C:\Temp\Autoruns\autorunsc64.exe -accepteula -a * > C:\Temp\Autoruns\output.txt
How can I type this up to work with C:\Program Files (x86)\Autoruns\autorunsc64.exe -a * > C:\Program Files (x86)\Autoruns\output.txt so it can run from these locations using PowerShell?
Very common question.
& "C:\Program Files (x86)\Autoruns\autorunsc64.exe"
Or even
C":\Program Files (x86)\Autoruns\autorunsc64.exe"
I would just add it to the path.

PostgreSQL syntax error at or near "$1"

sql"""copy updateTable
from $path
credentials 'aws_access_key_id=<my_access_key_id>;aws_secret_access_key=<my_secret_access_key>'
json '<path_to_s3_repository>'
gzip;""".update().apply()
Above command gives
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
when run on spark streaming using scala. What might be the issue? The resultant query runs fine when run from command line.
You cannot use a parameter with COPY.
You have to add the literal value of $path to the statement string and execute that.