Expect Script - Variables are Empty immediately after "Setting" Them?
Hello All,
I have embedded some expect code inside a Bash script I'm writing, but for some reason any variable I 'set' to something is
showing as empty immediately on the next line...
I haven't run into this problem before so I'm not sure what it could be...? I'm guessing it has something to do with the code
being embedded in another script..?
Here's my Code: And my Output:
Anyone know why the variables are NOT being set? I'm Stumpped..!!!
Any thoughts would be very much appreciated.
Thanks in Advance,
Matt
---------- Post updated at 04:51 PM ---------- Previous update was at 04:17 PM ----------
Figured it out...!!
You need to escape the '$' in front of any/all variables. I think this is due to using the "<<" which is open to variable expansion, so
I think that's why they need to be escaped...
So if the code is like this, it will work: *Notice the '\' in front of "\$my_var" in the puts statement...
And my Output:
Hopefully that helps someone in the same predicament I was in...
Yea, that should be fine, I don't think I'll need to do that in there anyway... Its just basically only like 10 lines or so of code, so nothing crazy
going on in there.
Anyway, thanks again for the info, much appreciated!
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Hi All,
i am trying to ssh to a remote machine and execute certain command to remote machine through script.
i am able to ssh but after its getting hung at the promt and after pressing ctrl +d i am gettin the out put as
expect: spawn id exp5 not open
while executing
"expect "$" {... (3 Replies)
Ladies & Gents,
Can one of you gurus please show me a very simple "expect" script to change the password in Solaris in a script, please? Nothing fancy, no error checking, no nothing. Just to change the password of a new user, it's all.
Many thanks in advance. U guys have honestly earned my... (1 Reply)
Friends,
Need someone's help in helping me with the below requirement for a script:
> For a list of servers(over 100+), I need to login into each of them(cannot configure password-less ssh) & grab few configuration details <
I know, this is possible through expect programming in a simple... (14 Replies)
Hi
I'm trying to run a script " abc.sh" which triggers "use.sh" .
abc.sh is nothing but a "expect" script which provides username and password automatically to the use.sh script.
Please find below the scripts:
#abc.sh
#!/usr/bin/expect -f
exec /root/use.sh
expect "*name*"
send... (1 Reply)
I'm trying to execute something like this:
exec perl -i -pe 's/\015/\012/g' '${file}'
in my expect script and I get:
error "invalid command name \"perl\".
however, if I run
perl -i -pe 's/\015/\012/g' "/Users/Shared/menu-items.txt"
directly in my terminal, it runs fine. I'm an... (4 Replies)
I nedd help on the below highlited one.
can any one explain on this,How its work in shell scripting.. then that will be very great full...
L_ABCD=${L_DBG:=N}
Thanks
Muddasas (3 Replies)
Hi
how to check input is "empty" and "numeric" in ksh?
e.g:
./myscript.ksh k
output show: invalid number input
./myscript.ksh
output show: no input
./myscript.ksh 10
output show: input is numeric (6 Replies)