Hello all,
I have following piece of code which is working fine if executed standalone -
When I try to embed it into following code highlighted in red it throws error, obviously I replaced date=$1 to julian_date_14 -
Error is below -
Any help will be greatly appreciated.
Thank you in advance!
Moderator's Comments:
Please refrain from using "urgent" in the subject - here are just volunteers at work which dislike stress
See my comment in your post on using "urgent" in the topic, thanks.
Your first script uses ksh syntax to declare an array with set -A. In your second script you use a shebang to call bash, which has a different syntax to declare an array like:
Last edited by zaxxon; 07-06-2017 at 09:28 AM..
Reason: added examples
See my comment in your post on using "urgent" in the topic, thanks.
Your first script uses ksh syntax to declare an array with set -A. In your second script you use a shebang to call bash, which has a different syntax to declare an array like:
Thanks again, I am just curious that I includedksh library in the starting of script by writing below code -
#!/bin/bash
#!/bin/ksh
#!/bin/sh
#!/bin/csh
Then why it picked up only bash syntax
The #! in exactly the first two character positions of a script tell the command interpreter which program to run to read and execute the script. All the other lines are pure comments and thus ignored. Nothing to do with libraries.
Since it is ksh code, if you put:
At the very beginning of your script then it should run fine, provided that you make the script executable (chmod +x) and run it like /path/to/script, or like script if the path leading to the script is in your search path.
If you start the script like
then that will not work, since the first line is simply a comment and ksh will not be used.
You can also make sure ksh is used by calling it like:
--
Quote:
Originally Posted by RudiC
The #! in exactly the first two character positions of a script tell the command interpreter which program to run to read and execute the script. [..]
Actually it is the first two bytes and they inform the OS' program loader that the file is a script and that the remainder of the line specifies which command interpreter to run, with the script name as argument. This command interpreter is subsequently started and it then reads the script and typically interprets this first line - that starts with #! (the "shebang") - as comment, because it starts with #.
Last edited by Scrutinizer; 07-08-2017 at 01:27 AM..
These 2 Users Gave Thanks to Scrutinizer For This Post:
Actually it is the first two bytes and they inform the OS' program loader that the file is a script and that the remainder of the line specifies which command interpreter to run, with the script name as argument.
In addition it might be worth adding that only absolute pathes are allowed here. This:
will work, whereas
will not, even if ../../something would correctly resolve to the executable.
hello,
i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case
i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N.
for case 1, I want to stretch N to fit M
arrayHuge
H = (... (2 Replies)
Hi folks,
A really dumb question as I've wasted far too long trying to get this to work.... (on RH bash)
I have an array:
m0='<hello>'
m0='<there>'
m0='<fred>'
v0='<goodbye>'
v0='<again>'
v0='<john>'
in my code I calculate the value of the variable to output and if I echo it, I... (2 Replies)
Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help.
pesudo code
if == ENDSINFIVEINTS ]]; then
do... (4 Replies)
I have an array and two variables as below,
I need to check if $datevar is present in $filename.
If so, i need to replace $filename with the values in the array.
I need the output inside an ARRAY
How can this be done.
Any help will be appreciated. Thanks in advance. (2 Replies)
Hi.
I´ve a script that should substitude the 8th line in a file called xxx.num6.
The "xxx" is set by an array filled with this command:
j=0
for Par in *.sys ; do
Par=`echo $Par | sed 's/\(.*\).sys/\1/'` ;
Par2="$Par" ; echo "${Par2}"
j=$((j + 1));
done
Now i try... (0 Replies)
I've created a series of arrays named as follows:
row1
row2
row3
.
.
.
row10
Each has 4 elements.
I'm trying to echo the array elements out in a for loop. Here's what I have:
for ((i=1;i<=10;i++))
do
for ((j=1;j<=4;j++))
do
eval out=${row`echo $i`}
echo -n $out (3 Replies)
Hi,
What is the actual difference between these two? Why the following code works for process substitution and fails for command substitution?
while IFS= read -r line; do echo $line; done < <(cat file)executes successfully and display the contents of the file
But,
while IFS='\n' read -r... (3 Replies)
Hello,
Please tell me if there is a better way to get the number of elements from an array that is passed to a function.
This is what works on Solaris 8 (ksh) but it looks odd:
loop_array() {
array_name=$2
b1='\${\#'
b2='}'
nr_elements=`eval echo... (6 Replies)
I am facing a strange error while creating posix threads:
Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output.
Snippet 1
This works:
--------------
int *threadids;
threadids = (int *) malloc (num_threads * sizeof(int));
... (4 Replies)
I am using an array (clmlist01). I have 61 of these and have 4 or more references to each one in a block of code that I do not want to have to hardcode. With that being said, I am creating a varible and going through a for loop to create the actually name of each array. The arrays would end up... (3 Replies)