Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Recently I have encountered a bug in my Linux kernel.
I am trying to perform the following command in my startup script called example.sh:
echo 1 > /var/opt/lab/example.log
5 out of 100 times in my Syslog I captured:
It shows me this error:
/usr/bin/example.sh: line 494: /var/opt/lab/example.log : Is a directory
From my understanding, i dont think this is possible.
I hope anyone can share some ideas with me.
I have two scripts called script A and script B let's say:
######################################Script A#################################
The logic in my script is this:
i will provide more detail here:
every time restart I need to check a flag file called flag which is in the same directory /var/opt/lab/
this flag only used once, once it's been detected i will do
if [ -d "/var/opt/lab/flag" ]; then
rm -rf /var/opt/lab/*
echo "Delete Factory files."
fi
then I also do:
if [ ! -d "/var/opt/lab/" ]; then
mkdir -p /var/opt/lab
echo "/var/opt/lab created"
else
echo "/var/opt/lab already exists"
fi
during normal operation the flag file is deleted then :
VALUE can be either 0 or 1 depends on the register value I read
echo "${VALUE}" > /var/opt/lab/example.log
##################Script B###################################
INDEX=`cat /var/opt/lab/example.log` ---------------------------------------------------> This is where the error raised: says it's a directory not a file
Based on the INDEX i will do different operations.
###########################################################################
[QUESTION]I can not determine where does this example.log directory comes from I need tips on trouble shoot this. Is it linux kernel driver related ?
Sorry, but is it /var/log/lab/example.log or /var/opt/lab/example.log now? In your script?
And are you sure there isn't a space between /var/.../lab/ and example.log, like so:
Code:
/var/.../lab/ example.log
???
Impossible to say anything further without knowing what else has access to that file. I assume you have "anonymised" that output for us?
Are you using /var/.../lab/example.log only once throughout the whole script, just to echo a "1" into it?
What else uses this file? What does it log?
Sorry, but is it /var/log/lab/example.log or /var/opt/lab/example.log now? In your script?
And are you sure there isn't a space between /var/.../lab/ and example.log, like so:
Code:
/var/.../lab/ example.log
???
Impossible to say anything further without knowing what else has access to that file. I assume you have "anonymised" that output for us?
Are you using /var/.../lab/example.log only once throughout the whole script, just to echo a "1" into it?
What else uses this file? What does it log?
It's /var/opt/lab/example.log now
Was a typo and I fixed it
(1) There is no space /var/opt/lab/example.log
(2)
The logic in my script is this:
i will provide more detail here:
every time restart I need to check a flag file called flag which is in the same directory /var/opt/lab/
this flag only used once, once it's been detected i will do
if [ -d "/var/opt/lab/flag" ]; then
rm -rf /var/opt/lab/*
echo "Delete Factory files."
fi
then I also do:
if [ ! -d "/var/opt/lab/" ]; then
mkdir -p /var/opt/lab
echo "/var/opt/lab created"
else
echo "/var/opt/lab already exists"
fi
during normal operation the flag file is deleted then :
VALUE can be either 0 or 1 depends on the register value I read
echo "${VALUE}" > /var/opt/lab/example.log
INDEX=`cat /var/opt/lab/example.log` ---------------------------------------------------> This is where the error raised: says it's a directory not a file
Based on the INDEX i will do different operations.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.