Solved

Perl and Linux Shell Scripting: escape @

Posted on 2013-11-13
5
377 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
  • 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 250 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 250 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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…

773 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