Skip to main content

Timeline for Evalute passed in variable in bash

Current License: CC BY-SA 3.0

16 events
when toggle format what by license comment
Apr 13, 2017 at 12:36 history edited CommunityBot
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Oct 7, 2011 at 12:39 vote accept frogstarr78
Oct 7, 2011 at 6:52 comment added rozcietrzewiacz Sorry, I lost the essential exec somehow :/ Works now.
Oct 7, 2011 at 6:50 history edited rozcietrzewiacz CC BY-SA 3.0
added 10 characters in body
Oct 6, 2011 at 22:40 comment added frogstarr78 I had considered that it was how I escaped the variable, however, it doesn't seem to work still. This is what I get: # dofor ~/tmp/hosts 'echo "trying $host :"; ssh -p 23 myuser@$host "ls -lh /"' /home/scott/bin/dofor: line 14: syntax error near unexpected token `3' /home/scott/bin/dofor: line 14: `done 3 < $1'
Oct 6, 2011 at 20:44 history edited rozcietrzewiacz CC BY-SA 3.0
added 247 characters in body
Oct 6, 2011 at 20:33 comment added rozcietrzewiacz See the last edit - no need to use any substitution if you use single quotes.
Oct 6, 2011 at 20:32 history edited rozcietrzewiacz CC BY-SA 3.0
added 360 characters in body
Oct 6, 2011 at 20:19 comment added rozcietrzewiacz I see. If that's te main point, I'll think about it... Meanwhile, I corrected the script to allow commands like ssh to steal your input without breaking the while-read-loop. (The previous version would exit after executing ssh if it prompted for password.)
Oct 6, 2011 at 20:17 history edited rozcietrzewiacz CC BY-SA 3.0
added 7 characters in body
Oct 6, 2011 at 20:02 comment added frogstarr78 not necessarily. I want the $argument, possibly multiple times, that I pass to the script to be evaluated in the context of the for loop
Oct 6, 2011 at 19:19 history edited rozcietrzewiacz CC BY-SA 3.0
added 154 characters in body
Oct 6, 2011 at 19:05 comment added rozcietrzewiacz So you mean to say you want to be able to use $host in different places in the command? But just once in each?
Oct 6, 2011 at 18:52 comment added frogstarr78 that's an alternate method sure, granted there's no way to ensure that the $2'th and $3'th arguments will always surround the argument that I've passed in, and want replaced by values from the file
Oct 6, 2011 at 18:42 history edited rozcietrzewiacz CC BY-SA 3.0
added 338 characters in body
Oct 6, 2011 at 18:36 history answered rozcietrzewiacz CC BY-SA 3.0