×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Quotes

Quotes

(OP)
Hi all. I have a newb question about quoting.

I have a script that executes the following:

$grepcmd = "/bin/grep ";

$listserv is a list of servers

$details is the type of OS

The following line calls each:
my $list = `$grepcmd $listserv $details`;

My problem is that a few of the servers have a strange character in the name e.g. server 1 (houston).

It seems to be having trouble with the space or the bracket but the grep doesn't work for these clients.

How can I amend this in the script? Would double quotes around $listserv work?

RE: Quotes

The backticks will take whatever is in those three variables and run it as if on the command line of your operating system (which is presumably some flavour of Unix). If the command you produce isn't valid unix syntax, it won't work.

But what is the above intended to do? Is it really necessary to go out to grep, when Perl has powerful string handling functions of its own?

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd

RE: Quotes

(OP)
Hi Chris,

It's intended to take in a list of servers i.e.

/bin/grep server 1 /usr
/bin/grep server 2 /var
/bin/grep server 1 (houston) /tmp

The problem is the "server1 (houston)" seems to be causing it problems

RE: Quotes

Quote:

It's intended to take in a list of servers
But why? What are you trying to do with that list of servers once you've got it? Going out to grep may not be the best way of doing whatever-it-is.

And how do you expect this:

CODE

my $list = `$grepcmd $listserv $details`; 
to be magically translated into this?:

CODE

/bin/grep server 1 /usr
/bin/grep server 2 /var
/bin/grep server 1 (houston) /tmp 

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd

RE: Quotes

(OP)
Hey I got it working in the end. this is exactly what it does:

/bin/grep server 1 /usr
/bin/grep server 2 /var
/bin/grep server 1 (houston) /tmp

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close