Solved

Perl and Linux Shell Scripting: escape @

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Fine Tune your automatic Updates for Ubuntu / Debian
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

728 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