Solved

Perl and Linux Shell Scripting: escape @

Posted on 2013-11-13
5
382 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…

820 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