Compare a string using sh shell

I am using SH shell and I am trying to compare a string with a variable’s value but the if condition is always execute to true. Why? Here is some code: Sourcesystem=”ABC” if [ “$Sourcesystem” -eq ‘XYZ’ ]; then echo “Sourcesystem Matched” else echo “Sourcesystem is NOT Matched $Sourcesystem” fi; echo Sourcesystem Value is $Sourcesystem … Read more

Take a full page screenshot with Firefox on the command-line

I’m running Firefox on a Xvfb in a VPS. What I want to do is to take a full page screenshot of the page. I can redirect Firefox to particular page using firefox http://google.com and take a screenshot (inside X) using ImageMagick import root -window output.jpg The problem is, most of the page need scrolling … Read more

commands not found on zsh [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 5 months ago. The community reviewed whether to reopen this question 5 months ago and left it closed: Original close reason(s) were not resolved Improve … Read more

How to check if a file exists in a shell script

I’d like to write a shell script which checks if a certain file, archived_sensor_data.json, exists, and if so, deletes it. Following http://www.cyberciti.biz/tips/find-out-if-file-exists-with-conditional-expressions.html, I’ve tried the following: [-e archived_sensor_data.json] && rm archived_sensor_data.json However, this throws an error [-e: command not found when I try to run the resulting test_controller script using the ./test_controller command. What is … Read more