How can I retrieve the "#" and "(" inside of the PowerShell script.
When I'm trying to npm config get proxy the proxy displayed is http://username:ZA%40(testpassword#domain:8080/ but I want to display is http://username:ZA#(testpassword#domain:8080/
TEST: git config --global http.proxy http://username:ZA%40%28testpassword#domain:8080 --replace-all
I am trying to display the "#" by using %40 and for "(" is %28.
I'm thinking if the reserved character "#" is in the side of "("
Please help me out of this problem.
Related
I am testing group migration using ADMT cmd line, but the migration is failing for a specific case when the OU name contains double quotes.
ADMT GROUP /n "TestGroup" /sd:Child.A.COM /sdc.CHILD.A.COM /td.COM /tdc.A.COM /to:"ParentOU/TEST!##$%^&*()_+{}|:"<>?[]\;',./" /intraforest:yes
In cmd this throws "> was unexpected at this time" and in powershell it keeps waiting for more parameters. The main purpose is to convert this to a c# script the migrates the users/groups but it failed in the testing phase with cmd/powershell. Is there any way to make this possible at least in C#?
I have tried escaping the double quotes with "", ^", ", `" but nothing seems to work. I have also tried assigning the value to a variable and using the variable in powershell. Using "" (as suggested in this Escaping special characters in cmd) is the only time the command runs but it still throws the following error.
Error: Unable to migrate groups. Unable to bind to container
'ParentOU/TEST!##$%^&()+{}|:<>?[];',./ /intraforest:yes'. Unable to
get distinguished name for
'A.COM/ParentOU/TEST!##$%^&;()+{}|:<>?[];',./ /intraforest:yes'. :
The parameter is incorrect. (0x80070057)
The same is working if I create another OU with same name except for the double quotes.
Please help in resolving this issue.
You can do solve it in different ways:
With escaping the characters with carets outside of the quote
setlocal EnableDelayedExpansion
set "to_param=ParentOU/TEST^!##$%^&*()_+{}|:"^^^^^<^^^^^>?[];',./"
call ADMT GROUP /to:"%%to_param%%"
The main problem will be the ADMT program, you need to know how it parses the arguments, particularly with regard to the rules how it escape quotes inside arguments.
You could test \" in set "to_param=ParentOU...\"^^^^^<^^^^^>?[];',./"
I would like to join strings for file name and shell script so I can run the command line in kdb for ftp transfer.
But there are quotations in quotation marks. not sure how to add / in there.
This is the code I have:
host:"abc.com";
usr:"def";
path:"get /home/eddie/abc.csv /home/terry/";
cmd:" " sv ("/home/kdb/eddie/ftp.sh";host;usr;path);
system cmd;
So the path will not have quotation mark and will be running error. How can I solve this problem?
You can escape quotes with \ e.g. "\"Matt\"" but I don't think that's your issue. It looks like you are attempting to use get in the system command. This is a kdb keyword and your OS will not recognise it. You should just be passing the location of the csv to your ftp script.
Edit:
You may also need sh in the system command.
cat test.sh
echo $1
system "test.sh hello"
sh: ./test.sh: Permission denied
'os
system "sh test.sh hello"
"hello"
Assuming that you simply want quotes within a string, it may just be as simple as using .Q.s1 aka -3!, see https://code.kx.com/q/ref/dotq/#qs1-string-representation
q)" " sv ("/home/kdb/eddie/ftp.sh";host;usr;.Q.s1 path)
"/home/kdb/eddie/ftp.sh abc.com def \"get /home/eddie/abc.csv /home/terry/\""
q)" " sv ("/home/kdb/eddie/ftp.sh";host;usr;-3!path)
"/home/kdb/eddie/ftp.sh abc.com def \"get /home/eddie/abc.csv /home/terry/\""
Ive got the following output from jq which I would like to following to happen:
each URL should be on its own line
remove the double quotes
remove The http and https if they exist
remove any :ports
The output is assigned to a variable OUTPUT and contains the following:
"test.test.io:1337" "https://www.test.io"
I tried the following
echo $ENDPOINTS | tr " " "\n" | sed 's/^http\(\|s\):\/\///g'
Which gives me:
"test.test.io:1337"
"https://www.test.io"
Need to mention this is on OSX
Try:
endpoints='"test.test.io:1337" "https://www.test.io"'
echo "$endpoints" | tr " " "\n" | sed 's/^"//; s/"$//; s~^https\?://~~; s/:[0-9]\+$//'
remove the double quotes
s/^"//; - remove " on beginning of the line
s/"$//; - remove " on ending of the line
remove The http and https if they exist
s~^https\?://~~ - remove http optionally s followed by :// on begining of thelin
remove any :ports
s/:[0-9]\+$// - remove : followed by at least one number on ending of theline
Note: upper case variables are by convention used for environment variable, like PWD UID COLUMNS LINES SHELL LC_CTYPE USER etc. Prefer lowercase variables in custom scripts.
I am trying to download a file which has symbol "(" in it;s URL.
I tried using wget and curl. Bash is not allowing it to be processed and throws "-bash: syntax error near unexpected token `('".
Any idea how to resolve it?
You should escape the character by adding a "\" before it. Like \( or \)
Add single quotes ' or double quotes " around the URL.
I hope someone found this useful.
In my case, I want to curl this file name data (1).rar
then it should be write like this in the terminal
http://example.com/data%20\(1\).rar
I encountered the same problem and solved that issue just by adding double quotes to the command what I am passing.
for eg:
git checkout "<branch_name>"
I am trying to open an SQL data connection using a PowerShell script and my password contains a $ sign:
$cn = new-object system.data.SqlClient.SqlConnection("Data Source=DBNAME;Initial Catalog=Catagory;User ID=User;Password=pass$word;")
When I try to open a connection it says:
Login failed
Escape it by using backtick (`) as an escape character for the dollar sign ($).
Also, try to enclose the statement in single-quotes instead of the double-quotes you are using now.