1 |
Holly Bostick wrote: |
2 |
> gentoo@×××××××.ch schreef: |
3 |
>>I think the problem come from the fact that echo is sudo-ed but the shell |
4 |
>>redirection isn't. |
5 |
>> |
6 |
>>Compare this: |
7 |
>>su -c "echo foo > /etc/portage/whatever" |
8 |
>>and |
9 |
>>su -c "echo foo" > /etc/portage/whatever |
10 |
>> |
11 |
>>The first one will succeed, but not the second. |
12 |
> |
13 |
> Well, it didn't work (this to all the respondents). |
14 |
> |
15 |
> "sudo echo 'media-video/xine-ui ~x86' >>/etc/portage/package.keywords" |
16 |
|
17 |
This groups *everything* as one shell parameter, so it attempts to |
18 |
execute a file named "sudo echo 'media-video/xine-ui ~x86' |
19 |
>>/etc/portage/package.keywords" in your path. |
20 |
|
21 |
>>>/etc/portage/package.keywords: Onbekend bestand of map |
22 |
> ("unknown file or folder") |
23 |
|
24 |
Of course, since it's extremely unlikely a file with that name exists. |
25 |
|
26 |
> sudo echo 'media-video/xine-ui ~x86' >>/etc/portage/package.keywords |
27 |
|
28 |
Now, you've completely left out the quotes, so the redirection is done |
29 |
in the user shell, not the sudo shell. Of course, your user can't write |
30 |
to that file so you get: |
31 |
|
32 |
> -bash: /etc/portage/package.keywords: Toegang geweigerd |
33 |
> (permission refused) |
34 |
|
35 |
You want: |
36 |
sudo "echo 'media-video/xine-ui ~x86' >> /etc/portage/package.keywords" |
37 |
|
38 |
This cause the command |
39 |
echo 'media-video/xine-ui ~x86' >> /etc/portage/package.keywords |
40 |
to be passed to the sudo shell which causes the bash built-in: |
41 |
echo |
42 |
to be called with the single parameter |
43 |
media-video/xine-ui ~x86 |
44 |
and have it's output appended to the file |
45 |
/etc/portage/package.keywords |
46 |
|
47 |
|
48 |
> I'm really lost. Where am I going wrong? |
49 |
|
50 |
You simply aren't being careful enough with you quotes and |
51 |
misunderstanding the intricacies of shell expansion and nesting. |
52 |
|
53 |
> Oh, btw, just remembered-- this is bash 3. Does that make a difference? |
54 |
|
55 |
No. |
56 |
|
57 |
-- |
58 |
Boyd Stephen Smith Jr. |
59 |
bss03@××××××××××.com |
60 |
|
61 |
-- |
62 |
gentoo-user@g.o mailing list |