How to execute command under if statement in Shell Script under expect condition?

Deb Paikar
send "if [ `ps -ef | grep ttyS1 | sed -n 1p | cut -d ' ' -f 2` -eq 'ttyS1' ]; then
not_found='false'
else 
not_found='true'
fi\r"

I have tried so many time with double quote and single quote also under ttyS1 but it is showing 1) ttyS1: unknown operand 2) Bad Number for double quote

Romeo Ninov

You use -eq which is for comparing numbers. Your = when you compare strings

send "if [ `ps -ef | grep ttyS1 | sed -n 1p | cut -d ' ' -f 2` = 'ttyS1' ]; then
not_found='false'
else 
not_found='true'
fi\r"

And you can use double quotes as they are used already. You can also leave string ttyS1 w/o any quotes

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to execute a shell command under Linux unsing QProcess?

how to execute java program under certain condition

How to execute a function with an isset under an if statement in PHP

How can I insert a 'with' statement under a condition?

How to execute arbitrary command under `bash -c`

how to execute a script within a script in shell command

os.system() execute command under which linux shell?

os.system() execute command under which linux shell?

Expect script to run shell command

How can I execute an MySQL command through a shell script using if -else for condition based?

How to execute a MySQL command from a shell script?

How execute specific command from shell script

how diff command behaves on if statement in shell script

How to pass argument in Expect through the command line in a shell script

Timeout Command under Expect not Working as Expected

How to execute remote pysftp commands under a specific shell

how do i rewrite the correct statement for COUNT under this condition

How to execute command under ssh remote machine and parse json value

Unable to execute the If condition in shell script

Is there any way to send if else statement to remote server while using expect command in shell script?

How can I run a shell script as a daemon under Redhat?

Execute two commands under condition in for loop in makefile

How while loop execute in the shell script for the FALSE condition?

Shell script to execute a command with iteration

execute printf command shell script

Shell script to execute psql command

How to execute shell command

Join under condition in Oracle SQL SELECT statement

Eclipse CDT preprocessor get statement under condition