本文介绍了如何在Linux上传递带有感叹号的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Python脚本,该脚本接收用户名和密码作为参数,但是我的密码包含两个感叹号.当我像这样调用脚本时

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?

推荐答案

您应该能够简单地将内容用单引号引起来.

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

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

这篇关于如何在Linux上传递带有感叹号的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-25 21:42