• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

scripting

how can we make the variables of one script available for the other script

generally the otehr script is mainly has execute commands
put ${TMPDIR}/${ZIPFILE} ${TARGETDIR}/${ZIPFILE} gets from other script

#!/usr/bin/expect

spawn sftp user@servername

expect "password:"
send "password\n"

expect "sftp>"
send "pwd\n"

expect "sftp>"
send "put ${TMPDIR}/${ZIPFILE} ${TARGETDIR}/${ZIPFILE}\n"

expect "sftp>"
send "bye\n"
0
nicky s
Asked:
nicky s
1 Solution
 
jeremycrussellCommented:
You could pass them as arguments.


#!/usr/bin/expect

set tmpdir [lindex $argv 0]
set zipfile [lindex $argv 1]
set targetdir [lindex $argv 2]

spawn sftp user@servername

expect "password:"
send "password\n"

expect "sftp>"
send "pwd\n"

expect "sftp>"
send "put $tmpdir/$zipfile $targetdir/$zipfile\n"

expect "sftp>"
send "bye\n"

Open in new window


And then from the shell prompt or another shell script call the expect script like

./expectscript ${TMPDIR} ${ZIPFILE} ${TARGETDIR}

Open in new window


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now