Avatar of Melodi Roberts
Melodi Roberts
Flag for United States of America asked on

LINUX Field Separators

We have a de-supported baseline shell script that runs jobs for Appworx.  After migrating from UNIX to LINUX, it no longer works to accept multiple values for a job parameter.  Attached is the code.  I do not know shell scripting, but am attempting to learn....  I was able to get something to work with field separators at the command line but have not yet gotten changes to work with the full script.

Does anyone know all that needs to be changed to get the field separation to work on LINUX?
BANJSUBP2_ONE
Linux* Unix* jobShell Scripting

Avatar of undefined
Last Comment
Melodi Roberts

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
arnold

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Melodi Roberts

I'd actually turned on the debugging to see that the piece of code that seems that it should be breaking apart a string using separator values was not working.  There is no fatal error occurring.  e.g. A parameter string might be ML~PM with '~' being the separator value.  The job being executed is only receiving the first value and not the second where more than one value is allowed and passed with the ~ separator.  I was hoping that someone could spot some code that perhaps works on UNIX but not LINUX as was the case for some of our other shell scripts that we migrated to LINUX, but it sounds like this is not the case. Thank you for your feedback.
arnold

This script seems to be called from another where some variables program, command, etc have to be set.
You have to make sure the same tools, awk, etc. are available and are within path.

You have to make sure that the same components that are available on UNIX are available/installed and since you use relative references that the commands are in the PATH

Do you have an example on what this script being called with?
Melodi Roberts

I do not have the example.  I am asking for access to more of the underlying code now, but I think I found a solution.

I played around with the line of code below because I could see it was not breaking apart the line based on the tilde/'~' character.

       var=`echo $line|awk '{{ FS = "~"}{ print $1}}'`

I changed it to what you see below  and although I need to do more testing, this appears to have done the trick.

     var=`echo $line | awk -F~ '{print$1}'`
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
arnold

do you have two separate accounts, you might want to check and have them consolidated into one.


In order to fix, it has to be identified what is broken or where or under what circumstance the data stream strays from the expected.
Melodi Roberts

ASKER
I thought I already pointed that out.  The issue is with the command below.
var=`echo $line|awk '{{ FS = "~"}{ print $1}}'`

It should take a line value of 1ML~2PM and print 1ML. It prints 1ML~2PM. I used an echo command to check on it.

When I changed the command to the command below it now works.
var=`echo $line | awk -F~ '{print$1}'`

Perhaps LINUX and our full set up with it does not support the FS command or something.

I will close out this issue and check on my EE accounts.  Thanks.
Melodi Roberts

ASKER
Thanks. Your feedback helped move me in the right direction with checking the FS command.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.