LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-05-2015, 03:04 AM   #1
sleftar
Member
 
Registered: Sep 2015
Posts: 50

Rep: Reputation: Disabled
How to assign eval command as a parameter


Hi guys. I wonder how can i assign

Quote:
eval echo `shuf -n 1 randmsg.txt`
this command as a parameter. Apparently

Quote:
a=eval echo `shuf -n 1 randmsg.txt`
echo $a
This method did not work for me.. Thanks.
 
Old 11-05-2015, 03:17 AM   #2
ondoho
Senior Member
 
Registered: Dec 2013
Posts: 4,176

Rep: Reputation: 834Reputation: 834Reputation: 834Reputation: 834Reputation: 834Reputation: 834Reputation: 834
do you want $a to contain a random line from randmsg.txt?
i don't think you need eval for that, so
Code:
a="$(shuf -n 1 randmsg.txt)"
should suffice.
 
Old 11-05-2015, 03:47 AM   #3
sleftar
Member
 
Registered: Sep 2015
Posts: 50

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
do you want $a to contain a random line from randmsg.txt?
i don't think you need eval for that, so
Code:
a="$(shuf -n 1 randmsg.txt)"
should suffice.
Hey thanks for the help. But when I try to send the parameter a as a message to a screen it gives this error on that screen

Quote:
a="$(shuf -n 1 randmsg.txt)"
screen -S screenname -X stuff $a^M
this prints a message on the screen that I want to send this message

Quote:
-X: stuff: no, one or two argument required

Last edited by sleftar; 11-05-2015 at 03:51 AM.
 
Old 11-05-2015, 02:06 PM   #4
ondoho
Senior Member
 
Registered: Dec 2013
Posts: 4,176

Rep: Reputation: 834Reputation: 834Reputation: 834Reputation: 834Reputation: 834Reputation: 834Reputation: 834
you forgot to put quotes around it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Security issues with BASH's eval command. towheedm Programming 12 06-08-2012 11:43 AM
Assign Command value to a variable rabir Linux - Newbie 10 05-21-2012 10:01 AM
[SOLVED] BASH eval + command fabtk Programming 5 03-09-2011 03:46 PM
use output of previous command as parameter to another command raviluchmun Linux - Newbie 4 11-14-2010 01:35 AM
[SOLVED] Effect of using eval to execute a command as opposed to writing it on the commandline daudiam Programming 1 06-20-2010 02:11 AM


All times are GMT -5. The time now is 03:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration