* [gentoo-user] [OT] Bash scripting 2
@ 2005-11-11 17:57 Peper
2005-11-11 18:23 ` Peter De Zutter
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Peper @ 2005-11-11 17:57 UTC (permalink / raw
To: gentoo-user
Hello,
How can i check whether i can create or overwrite a file?
For example:
If /etc/conf.d/net cannot be overwritten or created it return false.
Overwriting test would be -w /etc/conf.d/net, but how can i check if i can
create this file? I could check whether i can create new files
in /etc/conf.d, but how can i get /etc/conf.d/ from /etc/conf.d/net ?
--
Best Regards,
Peper
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] Bash scripting 2
2005-11-11 17:57 [gentoo-user] [OT] Bash scripting 2 Peper
@ 2005-11-11 18:23 ` Peter De Zutter
2005-11-11 18:25 ` Renat Golubchyk
2005-11-11 20:47 ` [gentoo-user] " Alexander Skwar
2 siblings, 0 replies; 6+ messages in thread
From: Peter De Zutter @ 2005-11-11 18:23 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 728 bytes --]
Hi,
you can check if the directory containing the file is writable, if it isn't
then you can't create a file.
Greetz
Peter
On 11/11/05, Peper <peper@aster.pl> wrote:
>
> Hello,
> How can i check whether i can create or overwrite a file?
>
> For example:
> If /etc/conf.d/net cannot be overwritten or created it return false.
>
> Overwriting test would be -w /etc/conf.d/net, but how can i check if i can
> create this file? I could check whether i can create new files
> in /etc/conf.d, but how can i get /etc/conf.d/ from /etc/conf.d/net ?
>
> --
> Best Regards,
> Peper
> --
> gentoo-user@gentoo.org mailing list
>
>
--
I have plenty of common sense,
I just choose to ignore it.
--- Calvin
[-- Attachment #2: Type: text/html, Size: 1086 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] Bash scripting 2
2005-11-11 17:57 [gentoo-user] [OT] Bash scripting 2 Peper
2005-11-11 18:23 ` Peter De Zutter
@ 2005-11-11 18:25 ` Renat Golubchyk
2005-11-11 18:33 ` [gentoo-user] " Peper
2005-11-11 20:47 ` [gentoo-user] " Alexander Skwar
2 siblings, 1 reply; 6+ messages in thread
From: Renat Golubchyk @ 2005-11-11 18:25 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 669 bytes --]
On Fri, 11 Nov 2005 18:57:40 +0100 Peper <peper@aster.pl> wrote:
> Hello,
> How can i check whether i can create or overwrite a file?
>
> For example:
> If /etc/conf.d/net cannot be overwritten or created it return false.
>
> Overwriting test would be -w /etc/conf.d/net, but how can i check if
> i can create this file? I could check whether i can create new files
> in /etc/conf.d, but how can i get /etc/conf.d/ from /etc/conf.d/net ?
$ dirname /etc/conf.d/net
/etc/conf.d
Cheers,
Renat
--
Probleme kann man niemals mit derselben Denkweise loesen,
durch die sie entstanden sind.
(Einstein)
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gentoo-user] Re: [OT] Bash scripting 2
2005-11-11 18:25 ` Renat Golubchyk
@ 2005-11-11 18:33 ` Peper
0 siblings, 0 replies; 6+ messages in thread
From: Peper @ 2005-11-11 18:33 UTC (permalink / raw
To: gentoo-user
> $ dirname /etc/conf.d/net
> /etc/conf.d
That's what i need, many thanks!
--
Best Regards,
Peper
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] Bash scripting 2
2005-11-11 17:57 [gentoo-user] [OT] Bash scripting 2 Peper
2005-11-11 18:23 ` Peter De Zutter
2005-11-11 18:25 ` Renat Golubchyk
@ 2005-11-11 20:47 ` Alexander Skwar
2005-11-12 0:48 ` [gentoo-user] " Peper
2 siblings, 1 reply; 6+ messages in thread
From: Alexander Skwar @ 2005-11-11 20:47 UTC (permalink / raw
To: gentoo-user
Peper schrieb:
> Hello,
> How can i check whether i can create or overwrite a file?
You need write access on the directory for creating files and
on the file for overwriting.
> For example:
> If /etc/conf.d/net cannot be overwritten or created it return false.
Use "test" or "[" or "[[".
> Overwriting test would be -w /etc/conf.d/net,
Yep.
> but how can i check if i can
> create this file?
[[ -w `dirname /etc/conf.d/net` ]] && echo can create file
> I could check whether i can create new files
> in /etc/conf.d,
Yep.
> but how can i get /etc/conf.d/ from /etc/conf.d/net ?
dirname. Or if you've got that in an environment variable,
you use "Parameter Expansion".
file=/etc/conf.d/net
echo ${file%/*}
Alexander Skwar
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gentoo-user] Re: [OT] Bash scripting 2
2005-11-11 20:47 ` [gentoo-user] " Alexander Skwar
@ 2005-11-12 0:48 ` Peper
0 siblings, 0 replies; 6+ messages in thread
From: Peper @ 2005-11-12 0:48 UTC (permalink / raw
To: gentoo-user
> file=/etc/conf.d/net
> echo ${file%/*}
I've gotten it working with dirname already, but this one is nice ;] Thanks
for help.
--
Best Regards,
Peper
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-11-12 0:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-11 17:57 [gentoo-user] [OT] Bash scripting 2 Peper
2005-11-11 18:23 ` Peter De Zutter
2005-11-11 18:25 ` Renat Golubchyk
2005-11-11 18:33 ` [gentoo-user] " Peper
2005-11-11 20:47 ` [gentoo-user] " Alexander Skwar
2005-11-12 0:48 ` [gentoo-user] " Peper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox