Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

shell - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

$ emailsender.py -u username -p 'pass!!'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...