Jump to content

Strange error about a little string in a simple script.


Sandro
 Share

Recommended Posts

Hi; I make a copy of principal config files using a very simple script:

sandro@ci74771ht ~ $ cat Scripts/Sync_config_files 
cat /etc/portage/make.conf > ~/Funtoo/make.conf
cat /etc/portage/package.mask |grep -v "#"|sort > ~/Funtoo/package.mask
cat /etc/portage/package.unmask |grep -v "#"|sort > ~/Funtoo/package.unmask
cat /etc/portage/package.use |grep -v "#"|sort > ~/Funtoo/package.use
cat /etc/portage/package.accept_keywords |grep -v "#"|sort > ~/Funtoo/package.accept_keywords
cat /var/lib/portage/world > ~/Funtoo/World
cat /etc/kernels/kernel-config-`uname -m`-`uname -r` > ~/Funtoo/kernel-config-`uname -m`-`uname -r`

But today make me error in the line 7. (permission denied).

 

If I rename the output file, the script works fine; but if i use as output `/Kernel-config-`uname -m`-`uname -r` i encounter the error

The permission in my Script direcoy are:

ls -lh Scripts/
totale 184K
-rw-r--r-- 1 sandro sandro   41 27 mar 22.03 Boinc_start
-rwxr--r-- 1 sandro sandro  102 14 apr 17.46 Cflags-test
-rw-r--r-- 1 sandro sandro  104 27 mar 22.03 Pulisci
-rwxr--r-- 1 sandro sandro  352 23 ago 19.07 Riabilita
-rw-r--r-- 1 sandro sandro   21 27 mar 22.03 Spegni_0444
-rwxr--r-- 1 sandro sandro  503 20 set 23.00 Sync_config_files

This is ery strange cause is from today that i encounter this trouble.

 

Making an experiment:

sandro@ci74771ht ~ $ echo kernel-config-$(uname -m)-$(uname -r)
kernel-config-4.0.5-gentoo-x86_64
 
it seems all ok.

 

and if i digit:

 

cat /etc/kernels/kernel-config-$(uname -m)-$(uname -r)
 
I can see my config-kernel.

 

But if i use the syntax from command line, i obtain the error

sandro@ci74771ht ~ $ cat ~/Funtoo/kernel-config-`uname -m`-`uname -r` > ~/Funtoo/kernel-config-`uname -m`-`uname -r`

It seems me strange, cause are years that i use this command ..... wh now this trouble ?

 

Thank You for any suggestion

 

Hi :)

Link to comment
Share on other sites


sandro@cit4771ht ~ $ ls -lah Funtoo/

totale 2,1M
-rw-r--r-- 1 sandro sandro  26K 28 giu  2014 271114_1930154566605_7035210_n.jpg
-rw-r--r-- 1 sandro sandro  26K 28 giu  2014 Pinguino_Gentoo.jpg
drwxr-xr-x 2 sandro sandro 4,0K 21 set 01.54 Scripts
-rw-r--r-- 1 sandro sandro 2,2K 23 set 01.26 World
-rw-r--r-- 1 sandro sandro   84  8 gen  2015 crons.cron
-rw-r--r-- 1 sandro sandro  24K 24 giu  2014 dvb-fe-tda10046.fw
-rw-r--r-- 1 sandro sandro  657  8 gen  2015 fstab
-rw-r--r-- 1 sandro sandro 1,6M 21 giu  2014 fw.zip
-rw-r--r-- 1 root   root   159K 23 set 01.32 kernel-config-x86_64-4.0.5-gentoo
-rw-r--r-- 1 root   root   159K 23 set 01.30 kernel-config-x86_64-4.0.5-gentoo.old
-rw-r--r-- 1 sandro sandro 2,2K 22 set 14.34 make.conf
-rw-r--r-- 1 sandro sandro  652 22 set 14.34 package.accept_keywords
-rw-r--r-- 1 sandro sandro    0 22 set 14.34 package.mask
-rw-r--r-- 1 sandro sandro   82 22 set 14.34 package.unmask
-rw-r--r-- 1 sandro sandro 1,2K 22 set 14.34 package.use
-rw-r--r-- 1 sandro sandro 8,1K  8 gen  2015 rc.conf
___________________________________________________________________________________
 
Damn .... I did not realize that two files were owned by root.
 
solved with
 
chown sandro:sandro /home/sandro/Funtoo *
 
2) Yes, i can use cp instead of cat: or use grep -E to make "slim" it
 
excuse for my distraction   :wacko:
 
Thank You very much   :)
Link to comment
Share on other sites

  • 2 weeks later...

 

sandro@cit4771ht ~ $ ls -lah Funtoo/

totale 2,1M

-rw-r--r-- 1 sandro sandro 26K 28 giu 2014 271114_1930154566605_7035210_n.jpg

-rw-r--r-- 1 sandro sandro 26K 28 giu 2014 Pinguino_Gentoo.jpg

drwxr-xr-x 2 sandro sandro 4,0K 21 set 01.54 Scripts

-rw-r--r-- 1 sandro sandro 2,2K 23 set 01.26 World

-rw-r--r-- 1 sandro sandro 84 8 gen 2015 crons.cron

-rw-r--r-- 1 sandro sandro 24K 24 giu 2014 dvb-fe-tda10046.fw

-rw-r--r-- 1 sandro sandro 657 8 gen 2015 fstab

-rw-r--r-- 1 sandro sandro 1,6M 21 giu 2014 fw.zip

-rw-r--r-- 1 root root 159K 23 set 01.32 kernel-config-x86_64-4.0.5-gentoo

-rw-r--r-- 1 root root 159K 23 set 01.30 kernel-config-x86_64-4.0.5-gentoo.old

-rw-r--r-- 1 sandro sandro 2,2K 22 set 14.34 make.conf

-rw-r--r-- 1 sandro sandro 652 22 set 14.34 package.accept_keywords

-rw-r--r-- 1 sandro sandro 0 22 set 14.34 package.mask

-rw-r--r-- 1 sandro sandro 82 22 set 14.34 package.unmask

-rw-r--r-- 1 sandro sandro 1,2K 22 set 14.34 package.use

-rw-r--r-- 1 sandro sandro 8,1K 8 gen 2015 rc.conf

___________________________________________________________________________________

 

Damn .... I did not realize that two files were owned by root.

 

solved with

 

chown sandro:sandro /home/sandro/Funtoo *

 

2) Yes, i can use cp instead of cat: or use grep -E to make "slim" it

 

excuse for my distraction :wacko:

 

Thank You very much :)

As soon as I read permission denied and saw that it used to work, I thought 'it was run as root and now root owns the file so you don't have permission'. Obviously, I know this because I've made the mistake myself.

 

That's why root's prompt is red and the system name is part of the prompt (ever been ssh'd to other systems and not realize you are in the wrong window?) I even make my home systems prompts a different color for the same reason and I keep 3 directory names showing in the prompt so I know if I'm in /usr/lib or /usr/local/lib and root has rm aliased to rm -i

 

Experience shows that its the simplest of mistakes that will bite us. Glad you got it worked out.

 

Taglines suck. https://eddon.systems

Link to comment
Share on other sites

Wow, Your explanation is very good !

 

And Also your link is fantastic :) 

 

I want to you (if you want) to mark you as a Friend in Funtoo Forums........

 

In Frenoode / #funtoo I'm sandro_

 

Thank You ;)

Link to comment
Share on other sites

Wow, Your explanation is very good !

 

And Also your link is fantastic :)

 

I want to you (if you want) to mark you as a Friend in Funtoo Forums........

 

In Frenoode / #funtoo I'm sandro_

 

Thank You ;)

Sure, glad it helped. My 'Stupid Admin Tricks' thread contains additional info and scripts (soon to be moved to my server)

 

Taglines suck. https://eddon.systems

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...