473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

open() flags

Hello everybody,

I just came accross a little problem, I think the answer must be
silly, but I may as well ask. I want open() to create a file if it
does not exist, or else open it, and then for it to append text to the
end of it. Which flags would I use ? I tried (O_CREAT | O_WRONLY |
O_APPEND) but that won't work...

Any help will be appreciated,
Cheers!

- Jeff
Nov 13 '05 #1
7 6545
Jeff <ag*******@netcourrier.com> scribbled the following:
Hello everybody, I just came accross a little problem, I think the answer must be
silly, but I may as well ask. I want open() to create a file if it
does not exist, or else open it, and then for it to append text to the
end of it. Which flags would I use ? I tried (O_CREAT | O_WRONLY |
O_APPEND) but that won't work... Any help will be appreciated,
Cheers!


Most like you'll be wanting comp.unix.programmer, as open() is not a
standard C function.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Parthenogenetic procreation in humans will result in the founding of a new
religion."
- John Nordberg
Nov 13 '05 #2
nrk
Jeff wrote:
Hello everybody,

I just came accross a little problem, I think the answer must be
silly, but I may as well ask. I want open() to create a file if it
does not exist, or else open it, and then for it to append text to the
end of it. Which flags would I use ? I tried (O_CREAT | O_WRONLY |
O_APPEND) but that won't work...

Any help will be appreciated,
Cheers!

- Jeff

As has been mentioned, this is off-topic in this group.

<OT>
but I am curious... what exactly is errno when the open fails, and what does
perror report? One likely reason could be that you don't have proper
permissions to create or access the file (errno is EACCES then).
</OT>

-nrk.
Nov 13 '05 #3
nrk <ra*********@deadbeef.verizon.net> wrote in message news:<dq**************@nwrddc03.gnilink.net>...
<OT>
but I am curious... what exactly is errno when the open fails, and what does
perror report? One likely reason could be that you don't have proper
permissions to create or access the file (errno is EACCES then).
</OT>


Yep that's the one. perror() prints "Permission denied", and errno is set to EACCES.

Sorry for posting on the wrong newsgroup, I will repost on comp.unix.programmer.

Cheers!

- Jeff
Nov 13 '05 #4
Jeff wrote:
Yep that's the one. perror() prints "Permission denied", and
errno is set to EACCES.


chmod might come in handy, as in chmod 644 your_file

Nov 13 '05 #5
Jeff <ag*******@netcourrier.com> spoke thus:
I just came accross a little problem, I think the answer must be
silly, but I may as well ask. I want open() to create a file if it
does not exist, or else open it, and then for it to append text to the
end of it. Which flags would I use ? I tried (O_CREAT | O_WRONLY |
O_APPEND) but that won't work...


Just for laughs, what's wrong with fopen( my_file, "a" )?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 13 '05 #6
nrk wrote:
Jeff wrote:

I just came accross a little problem, I think the answer must be
silly, but I may as well ask. I want open() to create a file if
it does not exist, or else open it, and then for it to append
text to the end of it. Which flags would I use ? I tried
(O_CREAT | O_WRONLY | O_APPEND) but that won't work...

As has been mentioned, this is off-topic in this group.

<OT>
but I am curious... what exactly is errno when the open fails,
and what does perror report? One likely reason could be that


Since you obviously know it is OT, and that there is no such
function as open in standard C, why do you ask about it here? Is
this some form of dyslexia? Or possibly attention deficit
disorder? Short-term memory loss (extending over entry of two
lines!)?

The answer will help us evaluate your future posts.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 13 '05 #7
nrk
CBFalconer wrote:
nrk wrote:
Jeff wrote:
>
> I just came accross a little problem, I think the answer must be
> silly, but I may as well ask. I want open() to create a file if
> it does not exist, or else open it, and then for it to append
> text to the end of it. Which flags would I use ? I tried
> (O_CREAT | O_WRONLY | O_APPEND) but that won't work...
>

As has been mentioned, this is off-topic in this group.

<OT>
but I am curious... what exactly is errno when the open fails,
and what does perror report? One likely reason could be that


Since you obviously know it is OT, and that there is no such
function as open in standard C, why do you ask about it here? Is
this some form of dyslexia? Or possibly attention deficit
disorder? Short-term memory loss (extending over entry of two
lines!)?

The answer will help us evaluate your future posts.

I made reasonable efforts to mark the off-topic contents in my post.
Perhaps you should brush up your reading and comprehension abilities if you
failed to spot that. Thankfully, the OP engaged his brain better than
yourself and moved to a more appropriate forum to raise his question.

-nrk.
Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Derek Basch | last post by:
Hello, I have a CGI script which uses anydb.open() to create a DBM. However I get this traceback: /usr/lib/python2.3/bsddb/__init__.py in hashopen(file='/var/www/bp/predictor/tools.dbm',...
0
by: Marco Nicosia | last post by:
Hello gang, My coworker and I are writing a Python class for the other developers within our team. This class is supposed to encapsulate several things, including daemonizing, setting up...
13
by: J. Campbell | last post by:
I'm wanting to output a text header file in front of the data portion of an output file. However when I use "\n" or "endl" as end of line, it just puts a 0x0a in the file(which is...
2
by: Richard Bell | last post by:
Newbie question ... please respond to group I'm trying to open/navigate to a url. How can I tell when the page is fully loaded? Testing suggest that window.open returns before the page is...
2
by: David | last post by:
Hello, I have an application that has been running for years and had little problem with it. We've been retesting the latest code under Windows 2003 and found a surprise. There is a certain...
11
by: pamelafluente | last post by:
I am doing my own PrintDialog, and have placed there a combo with the printer names, as in the PrintDialog provided by VB.NET. Here is the question: how do I open the native windows printer...
6
by: =?Utf-8?B?U2FtZWVrc2hh?= | last post by:
Hi, I want to write a simple .net program to open a URL, fill in fields, and click on a button to submit it using .net 1.1 framework. Can someone help in suggesting the libraries I should use?...
16
by: Gary Wessle | last post by:
Hi please help with this. std::fstream iofs( f.c_str(), std::ios::in|std::ios::out ); std::cout << f << '\n' << iofs.is_open() << std::endl; puts out...
2
by: swethak | last post by:
Hi, when i run my code it gives error as fopen(lib/providers//provider.RVLogic.php): failed to open stream: Permission denied in F:\Facebook\furniture11\Data...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.