hasrthur
hasrthur

Reputation: 1490

Ruby and system input

I have a command which is run with the system command. Could I log what is passed to the shell?

P.S. I've got the problems with qoutes =)

Upvotes: 0

Views: 183

Answers (2)

Eugene
Eugene

Reputation: 4879

You mentioned having "the problem with the quotes". I assume you mean double quotes? Modify Vapire's solution to this:

command = %Q{echo "double quoted string"}  # store the command as string
puts command                               # print it before you execute it
system(command)                            # execute it in the shell

Upvotes: 1

Vapire
Vapire

Reputation: 4578

You can simply print the string before you're sending it to system command

command = "whoami"  # store the command as string
puts command        # print it before you execute it
system(command)     # execute it in the shell

Upvotes: 1

Related Questions