Similar Threads:
1.How to use a variable in expect body which embedded in a shell script
XXXX@XXXXX.COM < XXXX@XXXXX.COM > wrote:
>> > pawn telnet '"$hostname"'>>>> Actually, I'm sorry for having posted it at all, because it is maximally>>>> unsafe. ...
>
> Thanks a lot for your prompt response. Does expect -c take things>
> between ' and ' as the code of expect?
Yes, and expect doesn't see the single quotes themselves.
>
> The code outside ' and ' will be taken as shell,
The shell, which also interprets the single-quotes according
to it's syntax (namely: "take everything literally, up to the
next single-quote") will also parse the "$hostname" and finally
create a single string that has all the parts concatenated, and
this string is then passed to expect, which takes it as if it
it had read it from a script-file.
>
> so "$hostname" was actually a shell style variable.
yes.
>
> So you can just omit those two ", like>
> expect -c '>
> set timeout 15>
> spawn telnet '$hostname'
One principially can, but that has an effect on what the shell
does with the contents of the variable. For sh-like shells,
(unlike tclsh!), there *is* a difference between $var and "$var",
but this difference is only relevant for values of var that
contain certain shell-meta-characters such as e.g. whitespace.
2.How to use a variable in expect body which embedded in a shell script
Hi all,
My question is how to use expect in a shell script. For example, here
is a little program, it just telnet to some host, and login root
automatically.
#!/bin/bash
echo "This is to test how to call expect in a shell"
#hostname=10.0.0.1
expect -c '
set timeout 15
spawn telnet 10.0.0.1
expect "login:" { send "root\r" }
expect "assword:" { send "abcd1234\r" }
interact
'
Can I use variable in the body of expect? Such as the 10.0.0.1 is a
variation passed to the shell scripts, like the following, actually
this is wrong, expect can't handle $hostname
#!/bin/bash
echo "This is to test how to call expect in a shell"
hostname=10.0.0.1
expect -c '
set timeout 15
spawn telnet $hostname
expect "login:" { send "root\r" }
expect "assword:" { send "abcd1234\r" }
interact
'
it will issue the following error.
[tina@kgardenia test]$ ./test.expect
This is to test how to call expect in a shell
can't read "hostname": no such variable
while executing
"spawn telnet $hostname"
Does anybody know how to use a variable in the body of the expect
code, which is embedded in a bash?
Many thanks to you all :D
3.import selected module variables within that module's procedures
I wish there were a way to import only a few module variables, derived
types, and procedures into a procedure of the module, for example
module foo_mod
integer :: i,j
contains
subroutine sub()
use foo_mod, only: i ! NOT a legal Fortran 95 statement
end subroutine sub
end module foo_mod
but one cannot write "use foo_mod" within module foo_mod. Is there a
way to get this effect in Fortran 95? Fortran 2003? Could the
"submodule" of TR 19767 accomplish this?
4.expect procedure name in procedure call(newbie)
Hello.
I've got 'expect procedure name in procedure call' warning but
I think my code is good
Inside testclass.adb I have Create function and when I'm trying to call
it from
main.adb unit I receive that error.
Below are full codes of my Ada units.
And by the way - how can I dynamically allocate memory for e.g. 10
elements(array of Floats)?
How can I reallocate them to 20 elements or 4?
How can I free the memory?
thanks in advance
best regards R
Codes:
main.adb:
--------
with testclass;
procedure Main is
object : testclass.rec1_Access;
begin
testclass.Create(object, 10);
end Main;
testclass.ads:
--------------
package testclass is
type rec1 is tagged private;
type rec1_Access is access rec1;
function Create(this: rec1_Access; s: Integer) return Integer;
private
type rec1 is tagged record
field: Integer;
end record;
end testclass;
testclass.adb:
--------------
package body testclass is
function Create(this: rec1_Access; s: Integer) return Integer is
begin
this.field :=s;
return this.field;
end Create;
end testclass;
5.Reply: expect procedure name in procedure call(newbie)
You are calling a function as though it were a procedure. This is
alright in C and C++, where the result is just silently thrown away,
but in Ada you have to do something with the result, such as assign it
or use it in a subsequent expression or routine call.
6. procedure inside package body and modelsim error
7. Clarion 5.5PE legacy application import procedure
8. Main procedure inside a package?