Solved

Perl and Linux Shell Scripting: escape @

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

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 61

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now