Is it on purpose that you mix the (deprecated) `...` and $(...) versions of "command substitution"?
No, it's not. 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.
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:
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
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.
So here
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
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)
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)
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)
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)
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)
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)
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)
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)