Daemon not executing shell file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Daemon not executing shell file
# 8  
Old 11-04-2016
Quote:
Is it on purpose that you mix the (deprecated) `...` and $(...) versions of "command substitution"?
No, it's not. Smilie I used what came into my mind first. But I will fix that. Is there anything else I should make better?

date is correctly executed, yes. The logs contain the correct date/time for every line and the if branches are triggered, the corresponding log lines are present.

jq works as well, I logged the variables and they are all set. $RETURN contains json and I need the unit-/systemcodes from different senders to identify which one was used. That works, too. The log contains every line it should contain.
# 9  
Old 11-04-2016
Did you print all the variables JUST before the tests are done?
This User Gave Thanks to RudiC For This Post:
# 10  
Old 11-04-2016
Sorry, I don't understand. Do you mean print the variables in the line directly preceeding the if-condition?

---------- Post updated at 03:42 PM ---------- Previous update was at 03:34 PM ----------

Well, it was the working directory.
Adding "cd /home/pi" solved it. But I was using absolute paths, could anybody explain what was wrong with that?

And thank you guys! That was really kind, I appreciate your help. Hope I can give sth in return some day. Smilie
# 11  
Old 11-05-2016
Sourcing means executing with dot . your env file you use in your profile, can be .profile, .kshrc .bashrc etc...
Let's say you just modified your environment like you just added an alias:
alias='ls -la' #this is for most sh and ksh, the syntax may differ for her and is for csh...
Now you want to test lets say you modified .kshrc, to test there is no need to log out and connect again, you can also:
Code:
 . ./.kshrc

Now you can also add the above to be executed at the beginning of your script, the only problem is your environment is done to meet interactive mode e.g standard input/output etc... are set, which is of no use and more gererates error when being set as for instance you dont have a display...
So either you accept all the errors hoping it will continue anyway ( because you are testing - you want to see there is something there missing for batchmode... ) you see it works so you are then left to find out what... Either you test if batchmode or interactive and use an if to skip what is set for interactive in your .profile
# 12  
Old 11-05-2016
I was also puzzled by your if test as it looked as you were comparing a char with a char or numeric ( -lt ) "$value" is to me a char ( or could be seen as a string of one or more characters... ) so it cant be less than as less than means you are dealing with numbers
To be sure I have a num in a variable affection I use e.g.
Code:
 let RING=0

So here
Code:
 if [ "$RING" -eq 1 ]

I really have a doubt but I am not a bash user and so maybe that can pass...
Only here is where things get tricky, on a true UNIX system init uses /bin/sh and its path is very.very limited: /bin:/usr/bin... And you dont know where you are: if it needs to write in current directory. depending where, you find yourself ( as user is pi..) with no permissions....
And I am not sure that a real Bourne shell would like the above if test... and so it will never execute what you expected
All that to say it may work for you but it may very well in that case, be portable, so complying to old standards have an advantage, old guys like some of us will very easily point out the errors or issues, using fancy last versions of shells that we may not use makes things far more difficult to read, understand and test...

All the best and welcome here

Last edited by vbe; 11-05-2016 at 10:18 AM.. Reason: Corrected but not sure I am very clear, sorry about that, English isnt my main language too
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compiling and Executing a Java File With a Shell Script

I'm trying to use a shell script to compile and execute a java file. The java classes are using sockets, so there is a client.java file and a server.java file, each with their own shell script. I also want to handle the command line arguments within the shell script, not the java classes. The... (1 Reply)
Discussion started by: britty4
1 Replies

2. Shell Programming and Scripting

Creating a Continuous File Reading-Executing Shell Script

I need to write something that will read and execute all the files(Mainly executable scripts) inside one or more folders; in other words, a continuous chain with a break when finished. I'm new to shell and need syntax help. I'm on Ubuntu 12.10-Gnome btw. Here are some main highlights I think... (2 Replies)
Discussion started by: linuxlololol
2 Replies

3. Shell Programming and Scripting

How to make a bash or shell script run as daemon?

Say i have a simple example: root@server # cat /root/scripts/test.sh while sleep 5 do echo "how are u mate" >> /root/scripts/test.log done root@server # Instead of using rc.local to start or another script to check status, I would like make it as daemon, where i can do the following: ... (2 Replies)
Discussion started by: timmywong
2 Replies

4. Shell Programming and Scripting

getting : No such file or directory while executing a shell script

Hi all, I am getting : No such file or directory while executing a shell script. But i have that corresponding file in the corresponding path. It also have executable rights. Please help me out in this Thanks in advance. Ananthi.U (7 Replies)
Discussion started by: ananthi_ku
7 Replies

5. Shell Programming and Scripting

Executing Multiple .SQL Files from Single Shell Script file

Hi, Please help me out. I have around 700 sql files to execute in a defined order, how can i do it from shell script (3 Replies)
Discussion started by: anushilrai
3 Replies

6. Shell Programming and Scripting

executing shell file in jva + tomcat

Colleagues, i have an jsp application which uses a servlet for controlling the request. the servlet uses a java class that will invoke a shell script. when i involked a shell script using java's runtime.exec command , it didnt work... applications used are tomcat5, Fedora 6 and java1.5.0_09... (1 Reply)
Discussion started by: jaganadh
1 Replies

7. UNIX for Dummies Questions & Answers

Executing shell file within another shell file

Hello Everybody I have a shell script file which contains certain intialisation.Initialisation section is around 20 lines.This initialisation section is required by 20 shell script files. Intialisation shell script contains only initialisation of variables and it is not a good practise to... (2 Replies)
Discussion started by: appleforme1415
2 Replies

8. Shell Programming and Scripting

Run shell script as a daemon

I have simple shell script that I run as cron job every hour of the day. I would like to make it a daemon that runs far more frequently like every 30 seconds or so, but I have never made daemon before. How can I do this? -Sam (7 Replies)
Discussion started by: Sammy_T
7 Replies

9. Shell Programming and Scripting

shell script as a daemon

hi, can i run a shell script as a daemon ? the shell script looks like this : can this be run as a service ?: thanks regards shann (1 Reply)
Discussion started by: massoo
1 Replies

10. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies
Login or Register to Ask a Question