1

Manual run of following command works fine

/jrr/bin/java -Xms14M -Xm14M -Dhttps.protocols=Tv1.2 -Dk.ts.client.protocols=TLSv.2 -jar /gq1/ust/classes/S.jar $(< /pass.txt)

but shell fails can't read "(< /pass.txt)": no such variable

!/usr/bin/expect

spawn ssh gq1@a732.co.com "/jrr/bin/java -Xms14M -Xm14M -Dhttps.protocols=Tv1.2 -Dk.ts.client.protocols=TLSv.2 -jar /gq1/ust/classes/S.jar $(< /pass.txt);cd /gucq1/gcust;mail -s 'Hello' sam@gm.com < logs.txt" expect "password" send "N0\r" interact expect eof.

  • please do not change question, as is my answer in completly useless. you asked a question about bash, then about expect, those ar two differents topic. would you kindly rollback to version 5 and ask a new question ? – Archemar Dec 14 '17 at 14:21
  • My apologies... I will change it to previous version. – SHaFqaT M Dec 14 '17 at 17:48
1

Try

command $(< abc.txt)

where

  • $(< ) construct will read file, strip end of line and replace in command line

More information in Bash's manual, chapter Command Substitution:

Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).

  • Need one more help please.. Manual run of following command works fine /jrr/bin/java -Xms14M -Xm14M -Dhttps.protocols=Tv1.2 -Dk.ts.client.protocols=TLSv.2 -jar /gq1/ust/classes/S.jar $(< /pass.txt) but shell fails can't read "(< /pass.txt)": no such variable #!/usr/bin/expect spawn ssh gq1@a732.co.com "/jrr/bin/java -Xms14M -Xm14M -Dhttps.protocols=Tv1.2 -Dk.ts.client.protocols=TLSv.2 -jar /gq1/ust/classes/S.jar $(< /pass.txt);cd /gucq1/gcust;mail -s 'Hello' sam@gm.com < logs.txt" expect "password" send "N0\r" interact expect eof. – SHaFqaT M Dec 14 '17 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.