Sponsored Content
Full Discussion: File creation problem
Top Forums Programming File creation problem Post 302741789 by powyama on Monday 10th of December 2012 01:12:42 AM
Old 12-10-2012
Linux File creation problem

I am creating a file to store data, but the file does not get created at all.
Code:
#include <unistd.h>
#define DEFAULT_ID 0

int main()
{
    int d, n=0;
    int sz, data=0;
    char fn[256];
    char *bv;
    snprintf(fn, 256, "bv", DEFAULT_ID);
    bv=fn;
    printf("%s\n", bv);
    if ((d = open(bv, O_RDWR | O_CREAT | O_TRUNC, 0644)) < 0) {
        printf("\n\nconfig_write::file error\n\n");
        return;
    }

    if ((n = write(d,(char*) data, sz)) != sz) {
        printf("\n\nconfig_write::  written successfully\n\n");
        close(d);
        unlink(fn);
        return;
    }
    printf("\n\nconfig_write:: (%d)\n\n", n);
    close(d);
}
output::
{245}: cc te.c
{246}: ./a.out
bv


config_write::  written successfully

{247}: 
{247}: ls -lrt | tail
-rwxrwxr-x   1 team   4232329 Dec  3 02:22 iswitchd.bv.n
-rw-r--r--   1 team     29471 Dec  3 20:44 config.txt
drwxrwxr-x   2 team      4096 Dec  4 01:14 ConfigSpecs.bak
drwxrwxr-x  28 team      4096 Dec  4 02:47 dist.config.up.dow
-rw-r--r--   1 team     29667 Dec  4 02:59 config.new
-rw-r--r--   1 team     29667 Dec  4 21:00 config2
-rw-r--r--   1 team     29667 Dec  4 22:59 config3
-rw-r--r--   1 team     33293 Dec  5 00:10 fc
-rw-rw-r--   1 team       603 Dec  9 22:04 te.c
-rwxrwxr-x   1 team      5480 Dec  9 22:05 a.out

the ls -lrt command also does not give the file createSmilie

Last edited by powyama; 12-10-2012 at 02:32 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

user creation problem

hello, Actually I want to create a user for our brower based custom application for the mail access from our mailserver(linux). I create user dummy and I granted all the privileages to dummy user and made dummy equivelent to root and if I tried to create a another user logging as dummy ... (1 Reply)
Discussion started by: jarkvarma
1 Replies

2. Shell Programming and Scripting

problem with link creation!!!!

I have a home directory namely /pto/ppa/ridbmw/etl/ Now i have various directorys below the home directory. For eg from the home directory if i say cd /roddata it changes to that directory. I think its kind of link (I don't know if it's hard or soft). Now i need to create a new directory and... (4 Replies)
Discussion started by: dsravan
4 Replies

3. Shell Programming and Scripting

Directory Creation problem

Hiiii, here is my script-- BackupLocation="$OPTARG" if ]; then echo "Either option l or L should be given to $Programname" echo "$Usage" echo "$Programname is terminated" ... (1 Reply)
Discussion started by: namishtiwari
1 Replies

4. Solaris

File creation problem

Hi to all, I am facing a strange problem on the Solaris-10 server. I am unable to create/write files on the server. After writing, when I go for the save, then it gives me and 'jag: I/O error'..where 'jag' is a file name. Please suggest me... Regards, Jagdish Machhi (2 Replies)
Discussion started by: jagdish.machhi@
2 Replies

5. HP-UX

Problem With exceutable file creation

Hello , I came up with a new problem during creation of an exceutable file. My application all the c files and links them to create a new executable file. Till last month everything was fine and yester day i tried to change one file and tried to create an exe file but unsuccesfull. I am... (8 Replies)
Discussion started by: jagan_kalluri
8 Replies

6. Shell Programming and Scripting

File Creation Problem

I recently got a problem with a program. It said that Create a file using shell script and insert details in it and take a String from the user and see whether it matches with any of the details of the String. I know how to create a file, insert details, but hw to check whether the String matches... (2 Replies)
Discussion started by: ramj
2 Replies

7. AIX

User creation problem

Hi, I am getting tired in creating several users in a day. Can anyone have a script to create several users in the same server, as well as, to create one user in several servers. where i have to put script and how to run the script. Waiting for your reply. Thanks in advance (5 Replies)
Discussion started by: udtyuvaraj
5 Replies

8. Programming

problem with xsd file creation

Hi every one, I am new to xml data files,I have two xml files with same data but only small difference as shown below <List> <number>1101</number> <Area>inner walls in a room.</Area> <Detection>less pressure.</Detection> <reason> <normal> <Component Num="15"... (1 Reply)
Discussion started by: veerubiji
1 Replies

9. Shell Programming and Scripting

Text file creation problem

Using KSH, I have one text file which just contains a list of distinct references on each line, e.g.; 123456789 987654321 15457544X 164450200 etc. The file will always be called "InputRefs.txt". The number of distinct refs will be different each time. For each line (distinct ref) I... (1 Reply)
Discussion started by: b.hamilton
1 Replies

10. UNIX for Advanced & Expert Users

LVM mirror creation problem

I apologize is this isn't an appropriate post for the 'advanced' UNIX, so please let me know if I should post this under UNIX for dummies, but here's my problem in a nutshell: I having problems creating a mirrored logical volume. I have created two new physical volumes ... (2 Replies)
Discussion started by: simonrodan
2 Replies
imgsc(1)						      General Commands Manual							  imgsc(1)

Name
       imgsc - Find HST GSC stars in FITS or IRAF image files

Synopsis
       imgsc [options] FITS or IRAF file(s)

Description
       Search  the  HST  Guide Star Catalog withing the area described by the world coordinate system in an image header.  This is a link to imcat
       rather than a separate executable.

Options
       -b [<RA> <Dec>]
	      Output in B1950, optional new image center in B1950 (FK4) RA and Dec

       -c <name>
	      Reference catalog (gsc, ujc, or tab table file

       -g <class>
	      Guide Star Catalog class (-1=all,0,3 (default -1)

       -h     Print heading, else do not

       -j [<RA> <Dec>]
	      Output in J2000, optional new image center in J2000 (FK5) RA and Dec

       -m [<bright magnitude>] <faint magnitude>
	      Limiting catalog magnitude(s) (default none, bright -2 if only faint is given)

       -n <num>
	      Number of brightest stars to print

       -p <scale>
	      Initial plate scale in arcsec per pixel (default 0)

       -s     Sort by RA instead of flux

       -t     Tab table to standard output as well as file

       -v     Verbose listing of processing intermediate results

       -w     Write tab table output file imagename.cat -z Use AIPS classic projections instead of WCSLIB; use CD matrix or CDELT instead of poly-
	      nomial solution.

See Also
       imcat(),imuac(),imusac(),scat()

Author
       Doug Mink, SAO (dmink@cfa.harvard.edu)

14 April 1998								WCS								  imgsc(1)
All times are GMT -4. The time now is 07:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy