How to pass variable with spaces from shell to expect?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to pass variable with spaces from shell to expect?
# 1  
Old 03-04-2012
How to pass variable with spaces from shell to expect?

I need call expect script from shell script and pass values some of which could contain space. How to make expect to treat such values as one variable?
# 2  
Old 03-04-2012
I believe if you double quote your variable when you can expect, it should work. Example:
Code:
my-expect-code "$shellvar1" "$shellvar2"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Pass shell Variable to awk

Hello, May i please know how do i pass the shell variable to awk expression in the below script. It is returning null #!/bin/bash UNINUM=720922 UNINUM_DESC=`awk -F'|' -v UNINUM=$2 '/UNINUM/ {print $4}' datafile` echo $UNINUM_DESC datafile 4|First|720194|asdasdad 4|First|720735|asdasdsa... (8 Replies)
Discussion started by: Ariean
8 Replies

2. Shell Programming and Scripting

How to use 'expect' to pass UID & Password to a "for loop" in shell script?

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)
Discussion started by: thisissouvik
14 Replies

3. AIX

How to use 'expect' to pass UID & Password to a "for loop" in shell script?

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... (2 Replies)
Discussion started by: thisissouvik
2 Replies

4. Shell Programming and Scripting

Pass awk array variable to shell

Hi, all suppose I have following myfile (delimited by tab) aa bb cc dd ee ffand I have following awk command: awk 'BEGIN{FS="\t"}{AwkArrayVar_1=$1;AwkArrayVar_2=$2};END{for(i=0; i<NR; i++) print i, AwkArrayVar_1, AwkArrayVar_2,}' myfileMy question is: how can I assign the awk array... (7 Replies)
Discussion started by: littlewenwen
7 Replies

5. Shell Programming and Scripting

Pass shell variable to gnuplot

Hi I am plotting a series of CDFs using gnuplot using plot "data" u 1:(1./x.) smooth cumulative I am doing this over many files and I need to tune the x value to the number of lines that meets a particular condition. Is it possible to get the line count from shell using cat file | grep... (7 Replies)
Discussion started by: jamie_123
7 Replies

6. UNIX for Dummies Questions & Answers

How to pass a variable from shell to awk

I know this topic has been dealt with previously, but the solutions I've seen don't work for me apparently. I need to pass a variable defined in the shell to one in awk: $ echo $var1 3 $ cat aaa aaa 1 bbb 2 ccc 3 ddd 4 eee 5I've tried this, without success: $ awk... (2 Replies)
Discussion started by: metaltree
2 Replies

7. Shell Programming and Scripting

Not able to pass string with spaces in shell

I have to pass a sentence in a file, the specs are as: cat run | sed 's/SRT/'$8'/g' | sed 's/plength/68/g' | sed 's/stcol/'$5'/g' | sed 's/encol/'$6'/g' | sed 's/brdtype/'$1'/g' | sed 's/brdtxt/'$3'/g' | sed 's/demotxt/Total '$2'/g' | sed 's/bantxt/ban_'$7'/g' | sed 's/validcodes/'$4'/g' >... (15 Replies)
Discussion started by: patilrakesh1984
15 Replies

8. Shell Programming and Scripting

Pass a string with spaces to a shell script

I'm a beginner and wasn't able to google my problem... I would like to pass a string with spaces to a shell script. my test_shell: #!/bin/sh -vx ####################################################### # generate_documentation (c) Ch.Affolter Nov. 2009 Version 1.0 #... (3 Replies)
Discussion started by: vivelafete
3 Replies

9. UNIX for Dummies Questions & Answers

How to Pass variable to shell Script

Hi , i am beginner to Unix, I have one small script which execute java programme,it has java command input output structure . Right now i have given Input output structure manually that is on same directory, now how can i pass that by commandline #!/bin/sh java Classjava input.txt... (5 Replies)
Discussion started by: sam70
5 Replies

10. Shell Programming and Scripting

Strip leading and trailing spaces only in a shell variable with embedded spaces

I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help. echo $SH_VAR | command_line Syntax. The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Discussion started by: jerardfjay
6 Replies
Login or Register to Ask a Question