?
Solved

Perl and Linux Shell Scripting: escape @

Posted on 2013-11-13
5
Medium Priority
?
414 Views
Last Modified: 2013-11-17
Using Perl and exec I want to do this to be echoed:
"hello@world"
#!/usr/bin/perl -w
exec "echo  \"hello@world\" "

Open in new window

0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 62

Expert Comment

by:gheist
ID: 39645115
print("hello!@#$%^&*()world");
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 39645132
You're missing an escape.
exec "echo  \"hello\@world\" ";

Open in new window


However, a "hello world" script would simply use the built-in print function rather using exec to go out to the shell.

print q("Hello@World");

Open in new window

0
 
LVL 16

Author Comment

by:hankknight
ID: 39645199
I cannot use print because I am trying to get it to work with curl:
#!/usr/bin/perl -w
exec "curl -kX -u \"nlbdmobz\@sharklasers.com\":password123 GET https://zqzqzqz555.couchappy.com/site/www/zzz/hello.txt";

Open in new window

0
 
LVL 62

Assisted Solution

by:gheist
gheist earned 1000 total points
ID: 39645225
You should use perl's LWP whose capabilities are on par with caling curl (or aria2 or wget for that matter)
0
 
LVL 28

Accepted Solution

by:
FishMonger earned 1000 total points
ID: 39645262
Whenever possible, you should try to avoid the "leaning tower escapes" by using the appropriate quoting method such as q() or qq() depending on the need for variable interpolation.

Is the perl script supposed to do anything after executing the curl command?  If so, then you don't want to use the exec function because that will exit the script replacing it with the curl process.  You probably should be looking at using the system function.

You could also look at using LWP::Curl - LWP methods implementation with Curl engine
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question