shell

Elasticsearch bash script not working but if I copy and paste in the terminal it works

I have creating a bash script to test my index, however this bash script it gives different results than if I copy directly the a CURL command in my termina different. I retrieve different result than if I launch my code with sh [filen-name] What can be happening? #!/bin/sh alias curl=”curl -s” echo “Delete index” curl -X DELETE “localhost:9200/products?pretty” echo…
Read more

bash script contain perl code – and run on Python

I’m trying to run bash script – that contains perl code in it – on Python. From some reason – it only execute the bash part and not the perl part. The Python code that call’s the bash Script is this : (2 options) bashCommand = “/bin/bash createUser.sh “+ str(self.emptyNameField.text()) +” “+ str(self.emptyPWField.text())+” ” + str(self.emptyGroupField.text()) os.system(bashCommand) subprocess.call([path+’createUser.sh’, str(self.emptyNameField.text()),str(self.emptyPWField.text()),str(self.emptyGroupField.text())]) And…
Read more

Cron ran sql does not spool to file

Running a sql script from sh works fine. The sql script only writes (in this simplified case) a date to a spool file. When running the file from cron it does not spool however. the sh (testsql.sh): #! /bin/sh . /private/someuser/.bashrc setenv PATH $PATH:/usr/kerberos/bin:.:/local/bin:/…. /prog/oracle/10.2.0/bin/sqlplus someuser/somepw@p208 @/project/myfullpath/OW_Server_list_SIS.sql the sql script (OW_Server_list_SIS.sql): spool /project/myfullpath/SIS_Server_list.txt select sysdate from dual; spool off; I…
Read more

Processing multiline variable in shell scrip

I have extracted the results of a query in a variable. echo “$a” TABLESPACE_NAME TOT_SIZE PCT_FREE DATAFILE —————————— ———- ———- ———– SYSTEM 1000 40.625 /u01/oracle/datafile1.dbf SYSAUX 1000 67.2375 /u01/oracle/datafile2.dbf USERS 55 96.3636364 /u01/oracle/datafile3.dbf UNDOTBS1 1000 98.0625 /u01/oracle/datafile4.dbf I need to check the location of datafile (/u01/oracle) for space ,then add a datafile for each tablespace. Basically what im trying to…
Read more

why the value "$?" is changed in the "if" condition

I’m confused by the problem about the value of “$?” recently in my study of shell.I write a demo script as follow: #!/bin/bash echo “good” if [ $? -ne 0 ];then echo “$? not equal 0” else echo “$? equal 0” fi echo “good” ret=$? if [ $ret -ne 0 ];then echo “$ret not equal 0” else echo “$ret equal…
Read more

Where is /bin/bash being changed to /bin/sh?

I’m catching the following error from my GNUmakefile, and I’m trying to understand why /bin/sh is being used: $ make diff /bin/sh: 541: Bad file descriptor rm -f cryptopp563.diff The recipe is: .PHONY: diff diff: -rm -f cryptopp$(LIB_VER).diff $(shell svn diff -r 541> cryptopp$(LIB_VER).diff) I understand where the 541 is coming from. But I don’t understand why my shell is…
Read more

Issue with Script

We have a script which is checking and sending an alert if process goes down. For some reason it is not capturing it properly for all the users and not sending the alerts in all scenarios. Please suggest what could be the problem. Environments – uatwrk1, uatwrk2, uatwrk3 ——- uatwrk100 ServerName – myuatserver Process to be checked – Amc/apache/bin/httpd Script…
Read more