Challenge with sh script using environment variables to check for file.
Hi All
Thanks for reviewing my question.
I have a sh script where I used an environmental variable for the directory for the file I need to check to ensure before executing a process.
I have confirmed the permissions and I can find the file if I use a hard coding of the directory. This is a Centos 7 distribution.
Here is the script below
The response from running the script
I am just looking for guidance as to where to look.
Thanks
Robert Stojkovic
Last edited by Scrutinizer; 06-12-2019 at 02:42 PM..
Reason: icode tags to code tags + extra code tags
The output of
produces
Note the two leading spaces, The first space is what used to be the + character and it is overwritten by the space after the ${IC_HOME} variable expansion.
This indicates a trailing carriage return character in the IC_HOME variable
Then:
produces the output:
Also here part of the text gets overwritten. /lib/taleo-integrationclient.jar ends up at the beginning of the line.
So again this indicates a trailing carriage return character in the IC_HOME variable.
My guess this variable is being set by another script and that this scripts contains CR-LF (Carriage Return + Line Feed) at the end, so it is in Windows format. It needs to be converted to Unix format (only a LF, no CR).
Convert the script in which the IC_HOME variable is set to Unix format like so:
Last edited by Scrutinizer; 06-13-2019 at 06:03 AM..
This User Gave Thanks to Scrutinizer For This Post:
I reviewed the environment file and found that it had the LF after the variable.
I corrected the issue and now the script can find with the variable and the hard coded.
Hi everyone,
I wrote a script that is supposed to be run by cron on a daily basis. It works just fine if I run it manually, but due to a lack of environment variables (which are available during my user session but not when cron runs the script) it keeps failing to run successfully.
Here's the... (2 Replies)
Hi,
I have around 10 environment variables in my shell script. i want to set this all in a file and just call that file in my shell script. How can i do that ? Please help. TIA! (6 Replies)
Hi All,
I am using ETL tool Datastage and is installed on Linux environment. Few environment variables are set in datastage. Now my requirement is to use those environment variables in a unix script.
Is there any option I can do it?
Sugeestions from people working on datastage and linux... (1 Reply)
Hello Everyone
I need to create a script file which must append some lines to a target text file, I'm using sed for windows, the script file look like this:
{
a\
STRINGTABLE DISCARDABLE\
BEGIN\
5, 150 {a\
#define RC_SHELL, "%ID_SHELL%"\
#define RC_NAME, "%ID_NAME%"\
END
}
... (1 Reply)
Hi,
In Cron file i'm using username and password hard-coded and now i wann to use environmental veraiables in cron file.
But Could you please guide me how to use these environmental variables in cron file ?
Thanks,
Shyamu.A (4 Replies)
Hi all!
I know that environment variables can be set on the .bashrc file, but I need to set them from a sh script. I saw a lot of websites that teach this but it doesn't work for me.
#!/bin/sh
DEKTOP=$DESKTOP=:/home/rrodrigues/Desktop
export DESKTOP
if I do echo $DESKTOP returns me... (10 Replies)
Hello!
For the moment some settings in my .bashrc contain the password of my company's firewall, which is not a good idea. I would like to use the string "PASSWORD" set in .bashrc and a script that changes all appearances of "PASSWORD" in the environment variables by the actual password (which... (4 Replies)
I cannot get the following substitution ($ORACLE_SID) to work:
The variable ORACLE_SID is set to wardin my environment. It has been exported.
I have a text file called test.dat:
/u07/oradata/${ORACLE_SID}/extab/finmart/summit/ps_voucher_line_crnt_ex.dbf... (2 Replies)
I am new to unix and would appreciate if someone could help.
I have an environment variable SourceFilePath=/db1/Src/test set on the unix server.
I want to expand this SHELL variable in a file using any command sed, awk etc
File contents is as follows:
var=$SourceFilePath/file.txt
... (2 Replies)
First: me == noob. Whats a good resource for shell script info cause I'm having trouble finding good info.
I'm writing a shell script to automate the setup of a flash 'page flip'.
My current code is below.
the page flip takes an xml file of format
<content>
<pages... (1 Reply)