Passing arguments to remote script from local script using except
<p>Hello Im newbie to Expect scripting. Im trying to call remote script using ssh spawn and passing commandline arguments to the remote script.But in remote script im getting null values. Please help to solve this issue. Is the problem with passing the arguments in except script?</p>

<p><strong>Local Expect script</strong></p>

<pre><code>#!/usr/bin/expect
set hana_schema [lindex $argv 1]
set table [lindex $argv 2]
set condition [lindex $argv 3]
set yyyymm [lindex $argv 4]
set targetdir [lindex $argv 5]
set split [lindex $argv 6]
set timeout 120
set ip XXXX.XXX.XX.XX
set user name
set password pass
set script /path-to-script/test.sh
# here I spawn a shell that will run ssh and redirect the script to ssh's

spawn sh -c "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$ip bash $hana_schema $table $condition $yyyymm $targetdir $split &lt; $script" "$hana_schema" "$table" "$condition" "$yyyymm" "$targetdir" "$split"
expect "Password:"
send "$password\r"

# and just wait for the script to finish
expect eof
</code></pre>

<p><strong>Remote script test.sh</strong></p>

<pre><code>hana_schema=$1
table=$2
condition=$3
yyyymm=$4
targetdir=$5
split=$6
echo "$hana_schema"
echo "$table"
echo "$condition"
echo "$yyyymm"
echo "$targetdir"
echo "$split"
</code></pre>