I am trying to use wget with a url that includes a "#" sign. No matter what I do to escape the character, it doesn't work. I've used \, ', and ". But none of them work. Does any one have any suggestions?
Thank you!
Send it as %23 if you really mean for it to have a hash. If you're trying to send a fragment, don't bother since the server won't care about it regardless.
maybe put uri around'' ? I believe it works
Are you quoting the url? It shouldn't be a problem if you are.
My guess is you're doing something like:
wget http://foo.com/#!/blah
Instead of:
wget "http://foo.com/#!/blah"
# is the shell script comment character.
Related
I'm trying to print a statement that looks like this: "Oh no!",
but I keep getting: Oh no! without the quotes.
This is the code I've been using:
print(exclamation.capitalize() + ("!") , "I yelled" + ".")
Please what am I missing?
In Python 3.6+, you can use f-strings to embed statements directly in the string.
Also, if you use single quotes to capture the string, you can use double-quotes in the string and they will print without needing to be escaped.
print(f'"{exclamation.capitalize()}"! I yelled.')
In an Applescript I am trying to pass on a URL that I receive as an argument to a do shell script command to use it with curl.
With regular characters the procedure works fine, but as soon as my argument contains special characters like Umlauts, it gets all funky.
curl does download something, but replaces the letter Ü with à etc., which of course will not get me the correct result.
What do I need to do, to get this to work? I am neither very skilled with Applescript nor with encoding issues.
My setup at the moment is as follows:
set download_URL to item 1 of arguments
do shell script "curl " & download_URL & " > targetFile.html"
Some examples of what happens:
Äquivozität ---> Ãquivozität
Ökolikör ---> Ãkolikör
Übermütigkeit ---> Ãbermütigkeit
Schweißfuß ---> SchweiÃfuÃ
Which makes my confusion even greater. All Ä, Ö, Ü and ß render as Ã, but both in the editing mask here and in the one of the site in question they render as shown in this image.
Also, through some amateurish digging in the html-File, I figured out that instead of the letter Ü, I would need to pass the letters %C3%9C. So the whole procedure does work, if I pass %C3%9Cbermut instead of Übermut. However, I would of course like to avoid creating a translation table for all diacritics.
Can somebody figure out, what specific encoding problem is happening here?
After some more researching, I found out that what I need to urlEncode my string. That way, the letter Ü will be replaced with %C3%9C and it works for my purposes.
Applescript does not seem to support this natively, but one can use php to do the conversion. I found the method here: https://discussions.apple.com/message/9801376#9801376
So, in my case I used it like this:
set keyword to item 1 of arguments
set encodedKeyword to do shell script "php -r 'echo trim(urlencode(" & "\"" & keyword & "" & "\"));'"
do shell script "curl https://www.myUrl.com/" & encodedKeyword & ".html > targetFile"
This way, it works for me.
In case there is a better way - maybe something that works in Applescript directly - feel free to post another answer, then I'll change the accepted answer.
I am trying to check sql connection via sqlplus command in perl.
I have used the following code to do this.
print "Befores\n";
$rc=system("sqlplus system/system #sqlfile.sql");
print "After $rc\n";
sleep(10);
The returnes value in rc is 0 this time. But when I give wrong credentials like. The sqlfile.sql file contains the only sql command 'EXIT'.
$rc=system("sqlplus systemabc/system #sqlfile.sql");
This also ends with the return code 0. But, manually doing the Credentials are wrong.
Help me out in solving this...
Thanks in advance. :)
Yes dear friens,,,
It's working fine now.
I just added '\' before #sqlfile.sql, i.e, I escaped the '#' symbol and I mentioned the database name after my password. Now I am getting the perfect output. :)
The change is as bellow:
$rc=system("sqlplus -L system/system#tstdb1 \#sqlfile.sql");
Here the format I used is:
sqlplus -L Uname/Password#DBName \#SqlFileContainingMySQLQuries
And -L Specifies not to reprompt for username or password if the initial connection does not succeed. For more info goto About SQLPLUS
I also tried without escaping the '#' symbol before sqlfile.sql, But the change also should apply for inverted comas, I used Single inverted comas instead of double inverted comas as bellow as mentioned by #René Nyffenegger :
$rc=system('sqlplus -L system/system#tstdb1 #sqlfile.sql');
Here the format I used is:
sqlplus Uname/Password#DBName #SqlFileContainingMySQLQuries
This also works fine.
Yeah... :) I too tried this, Thanks for the answer #user252025
I was doing:
$rc=system("sqlplus -L user/user \#sql_file.sql");
Da rtrn code was wrong for me
Now I ve changed to
$rc=system("sqlplus -L user/user#Mydb \#sql_file.sql");
Its working fine..
Thanks again...
The problem is the line
$rc=system("sqlplus system/system #sqlfile.sql");
You have a string quoted with double quotes ("..."). Such strings try to epxand variables (starting with #, $ and %). Since you have #sqlfile in the string, perl assumes this to be an array (which, of course it is not).
Remedy:
$rc=system('sqlplus system/system #sqlfile.sql');
Why are you doing this? DBI exists to provivide a sane and secure way of using databases and sensibly getting the output/return/errors from them.
How do I make the parameter file of the method sound become the file name of the .fifo >extension using single quotes? I've searched up and down, and tried many different >approaches, but I think I need a new set of eyes on this one.
def sound(file)
#cli.stream_audio('audio\file.fifo')
end
Alright so I finally got it working, might not be the correct way but this seemed to do the trick. First thing, there may have been some white space interfering with my file parameter. Then I used the File.join option that I saw posted here by a few different people.
I used a bit of each of the answers really, and this is how it came out:
def sound(file)
file = file.strip
file = File.join('audio/',"#{file}.fifo")
#cli.stream_audio(file) if File.exist? file
end
Works like a charm! :D
Ruby interpolation requires that you use double quotes.
Is there a reason you need to use single quotes?
def sound(FILE)
#cli.stream_audio("audio/#{FILE}.fifo")
end
As Charles Caldwell stated in his comment, the best way to get cross-platform file paths to work correctly would be to use File.join. Using that, your method would look like this:
def sound(FILE)
#cli.stream_audio(File.join("audio", "#{FILE}.fifo"))
end
Your problem is with your usage of file path separators. You are using a \. Whereas this may not seem like a big deal, it actually is when used in Ruby strings.
When you use \ in a single quoted string, nothing happens. It is evaluated as-is:
puts 'Hello\tWorld' #=> Hello\tWorld
Notice what happens when we use double quotes:
puts "Hello\tWorld" #=> "Hello World"
The \t got interpreted as a tab. That's because, much like how Ruby will interpolate #{} code in a double quote, it will also interpret \n or \t into a new line or tab. So when it sees "audio\file.fifo" it is actually seeing "audio" with a \f and "ile.fifo". It then determines that \f means 'form feed' and adds it to your string. Here is a list of escape sequences. It is for C++ but it works across most languages.
As #sawa pointed out, if your escape sequence does not exist (for instance \y) then it will just remove the \ and leave the 'y'.
"audio\yourfile.fifo" #=> audioyourfile.fifo
There are three possible solutions:
Use a forward slash:
"audio/#{file}.fifo"
The forward slash will be interpreted as a file path separator when passed to the system. I do most my work on Windows which uses \ but using / in my code is perfectly fine.
Use \\:
"audio\\#{file}.fifo"
Using a double \\ escapes the \ and causes it to be read as you intended it.
Use File.join:
File.join("audio", "#{file}.fifo")
This will output the parameters with whatever file separator is setup as in the File::SEPARATOR constant.
After a bit of googling and searching here, couldn't find the answer to this silly question!
For a structure like this...
dirZero
|---dirOne
|---|---myProgram.exe
How do I run "myProgram" if my current directory is dirZero? I.E.,
C:\dirZero> dirOne/myProgram.exe
...which obviously doesn't work.
You should use a backslash \, instead of forward slash. /
C:\dirZero> dirOne\myProgram.exe
Or, wrap it with double quotes "
C:\dirZero> "dirOne/myProgram.exe"
Use a backslash instead
C:\dirZero> dirOne\myProgram.exe
probably u should just simple use
cd C:\dirZero\dirOne
C:\dirZero\dirOne> myProgram.exe