shell - Expand passed arguments before printing with puts to virtual server -


i having trouble expect script not evaluating arguments. in puts ${file_id} block (simplified obviously) gets placed onto virtual machine , later used configuration. block see puts same code local directory me see if things working properly.

global env set env(os1) [lindex $argv 0] set env(scratch_repo) /tmp/yum.repo_[pid] set file_id [ open ${env(scratch_repo)} "w"]  puts ${file_id} {  root_image=node-${env(os1)} if {[string first r ${env(os1)}] == 0} {     create_node_byid 1 [string range ${env(os1)} 0 4]-64 } else {     create_node_byid 1 [string range ${env(os1)} 0 5]-64 } } 

unfortunately, log file looks above. arguments not being substituted , can't figure out why. i've tried using regular variables, different syntax referencing local , global variables have had no luck getting work. thoughts?

as etan reisner pointed use double quotes in puts command instead of braces, replaced.

puts ${file_id} " root_image=node-${env(os1)} if {[string first r ${env(os1)}] == 0} {     create_node_byid 1 [string range ${env(os1)} 0 4]-64 } else {     create_node_byid 1 [string range ${env(os1)} 0 5]-64 } " 

assuming env(os1) ubuntu, produce following content in file

root_image=node-ubuntu if {-1 == 0} {     create_node_byid 1 ubunt-64 } else {     create_node_byid 1 ubuntu-64 } 

note : variable substitutions not evaluation of code such. i.e. if-else commands won't evaluated.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -