Sponsored Content
Full Discussion: cannot save file...
Top Forums Programming cannot save file... Post 41646 by szzz on Friday 10th of October 2003 07:25:32 AM
Old 10-10-2003
cannot save file...

Hello! I have a problem:

I compile some function, which must save file:
=====================
// prog.cpp
void save_file(){
FILE *fs = fopen("file.txt", "w");
if(!fs) cerr<< "cannot save";
fprintf(fs, "This is a text file.");
fclose(fs)
}
=====================
If i compile it from command command line
...root]# g++ prog.cpp
...root]# ./a.out
It starts and saves file normally.
But if i run this function in a programm from as CGI
programm(in Apache) - it doesn't save file! Says "cannot save"...

Maybe it s a problem with permissions? I have neard, that
Apache executes everything in "cgi-bin" as a user "nobody" -
maybe this is a reason? If it is, how can I cnange the permissions
and to what? Is there a function in C++ for permissions changing?
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Can't save a file

There is a file A.lcf. I am updating the file and saving it . But as soon as I am logging off and then logging in I am finding that the updated changes are not there in the file. (5 Replies)
Discussion started by: suchismitasuchi
5 Replies

2. Shell Programming and Scripting

Data fetched from text file and save in a csv file

Hi i have wriiten a script which fetches the data from text file, and saves in the output in a text file itself, but i want that the output should save in different columns. I have the output like: For Channel:response_time__24.txt 1547 data points 0.339 0.299 0.448 0.581 7.380 ... (1 Reply)
Discussion started by: rohitkalia
1 Replies

3. Shell Programming and Scripting

Save cURL verbose output to file or do it like browser "save as.."

hi there ! i have exactly the same problem like this guy here https://www.unix.com/shell-programming-scripting/127668-getting-curl-output-verbose-file.html i am not able to save the curl verbose output.. the sollution in this thread (redirecting stderr to a file) does not work for me.... (0 Replies)
Discussion started by: crabmeat
0 Replies

4. UNIX for Dummies Questions & Answers

how to save changes to a file

is i want to sort or delete lines etc etc to a file, how do i save the changes. example i do sort file > file when i do cat file, all data is erased. thanks. (2 Replies)
Discussion started by: hobiwhenuknowme
2 Replies

5. Shell Programming and Scripting

Read file and for each line replace two variables, add strings and save output in another file

Hi All, I have a file, let's call it "info.tmp" that contains data like this .. ABC123456 PCX333445 BCD789833 I need to read "info.tmp" and for each line add strings in a way that the final output is put /logs/ua/dummy.trigger 'AAA00001.FTP.XXX.BLA03A01.xxxxxx(+1)' where XXX... (5 Replies)
Discussion started by: Andy_ARG
5 Replies

6. Shell Programming and Scripting

cut lines from log file and save it another file

Dears, i want cut the lines from a log file. Example of the log file as follows.. May 27, 2011 5:54:51 PM com.huawei.ivas.utilities.sm.client.SMDeliverContrUtil isDeliverSM FINE: May 27, 2011 5:54:51 PM com.huawei.ivas.utilities.sm.client.SMUtil addSysUpMsgLog INFO: . The message content... (1 Reply)
Discussion started by: tonypalokkaran
1 Replies

7. UNIX for Dummies Questions & Answers

CSV file:Find duplicates, save original and duplicate records in a new file

Hi Unix gurus, Maybe it is too much to ask for but please take a moment and help me out. A very humble request to you gurus. I'm new to Unix and I have started learning Unix. I have this project which is way to advanced for me. File format: CSV file File has four columns with no header... (8 Replies)
Discussion started by: arvindosu
8 Replies

8. Shell Programming and Scripting

FILE_ID extraction from file name and save it in CSV file after looping through each folders

FILE_ID extraction from file name and save it in CSV file after looping through each folders My files are located in UNIX Server, i want to extract file_id and file_name from each file .and save it in a CSV file. How do I do that? I have folders in unix environment, directory structure is... (15 Replies)
Discussion started by: princetd001
15 Replies

9. Shell Programming and Scripting

Opening a file in vi and automatically save and quit this file using shell script

Hi friends, In my shell script, I want to open a file using vi editor. After opening the file in vi, I want to save and quit this file automatically.... all through shell script. the code segment is: ------------------------------------------------------------ cd ~/netfpga/projects/scone/sw/... (2 Replies)
Discussion started by: sachinteotia
2 Replies

10. Shell Programming and Scripting

Save value from output of Corestat and save in a list for each core

I am trying to modify the "corestat v1.1" code which is in Perl.The typical output of this code is below: Core Utilization CoreId %Usr %Sys %Total ------ ----- ----- ------ 5 4.91 0.01 4.92 6 0.06 ... (0 Replies)
Discussion started by: Zam_1234
0 Replies
GETC(3) 						     Library Functions Manual							   GETC(3)

NAME
getc, getchar, fgetc, getw - get character or word from stream SYNOPSIS
#include <stdio.h> int getc(FILE *stream) int getchar(void) int fgetc(FILE *stream) int getw(FILE *stream) DESCRIPTION
Getc returns the next character from the named input stream. Getchar() is identical to getc(stdin). Fgetc behaves like getc, but is a genuine function, not a macro; it may be used to save object text. Getw returns the next int from the named input stream. It returns the constant EOF upon end of file or error, but since that is a good integer value, feof and ferror(3) should be used to check the success of getw. Getw assumes no special alignment in the file. SEE ALSO
clearerr(3), fopen(3), putc(3), gets(3), scanf(3), fread(3), ungetc(3). DIAGNOSTICS
These functions return the integer constant EOF at end of file, upon read error, or if an attempt is made to read a file not opened by fopen. The end-of-file condition is remembered, even on a terminal, and all subsequent attempts to read will return EOF until the condi- tion is cleared with clearerr(3). BUGS
Because it is implemented as a macro, getc treats a stream argument with side effects incorrectly. In particular, `getc(*f++);' doesn't work sensibly. 7th Edition May 14, 1986 GETC(3)
All times are GMT -4. The time now is 06:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy