Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass argument with exclamation mark on Linux?

I have a simple Python script that receives username and password as arguments, but my password contains two exclamation marks. When I call my script like

salafek@dellboy:~/Desktop/$ emailsender.py -u username -p pass!! 

a command that I entered earlier replaces the exclamation marks:

salafek@dellboy:~/Desktop/$emailsender.py -u username -p "passemailsender.py -u username -p passwget wget http://www.crobot.com.hr/templog" 

I can escape exclamation marks with backslash (\), but my password changes.

Is there solution for this, how can I escape exclamation marks without changing my password?

like image 768
salafek Avatar asked Jul 27 '10 18:07

salafek


People also ask

How do you use an exclamation mark in Linux?

Exclamation mark is for "Not" (like in boolean), -d flag is for folder exists in bash. It's not in the question by it may be worth mentioning for someone else reading this that && does short-circuit evaluation, so the condition to the left must be true for the condition to the right to be evaluated.

What is $@ in Linux?

$@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc.

How do I type an exclamation point in bash?

The exclamation mark is part of history expansion in bash. To use it you need it enclosed in single quotes (eg: 'http://example.org/!132' ). You might try to directly escape it with a backslash ( \ ) before the character (eg: "http://example.org/\!132" ).


1 Answers

You should be able to simply wrap things in single quotes in the shell.

$ emailsender.py -u username -p 'pass!!' 
like image 178
Joe Kington Avatar answered Oct 01 '22 18:10

Joe Kington