Programming :: How To Avoid Overwriting A File

Sep 6, 2010

I'm facing difficulty while writing to an already existing file . I'm making a shell (programming in C). I want a file (say , logfile) to keep a record of all the commands a user enters. For the first command it runs fine , but for the second time and thereafter it overwrites the previous contents. How do I avoid this?

View 3 Replies


ADVERTISEMENT

OpenSUSE Install :: How To Avoid Windows MBR From Overwriting And Corrupting Grub

Jul 18, 2011

I had opensuse/winxp running.

First windows xp wouldn't boot - then opensuse **** out and I had nothing but a black screen. I spent about two days trying to figure out what in god's name happened. I finally got a copy of winxp recovery disk and it couldn't find the partition that windows was on. That gave me some idea of what was going on. So I tried to fix the matter from partitionmagic. I reinstalled grub making sure that everything was associated properly. I still couldn't get either opensuse or windows to boot after many many different trial and error attempts.

After deciding there was no help for it. I decided to slave my hard drive and wipe to start over. So I booted partition magic from USB and deleted my opensuse partition and -what do you know - windows booted right up. Aside from feeling windows xp's smug grin as the logo appeared - i am perplexed as to how this happened. My guess is that MBR tried to overwrite grub. But I think that the loader was confused and trying to boot from the wrong partition.

I want to reinstall opensuse again. However I want to make sure that this doesn't happen. I need my xp partition for examsoft because wine doesn't seem to work for it and I can't vbox it. So is there some way to make sure that when I do install from DVD on my USB that:

1) repositories are correct
2) MBR doesn't overwrite grub (should I install Grub2 or LILO?)

View 4 Replies View Related

Programming :: Script To Copy Paste Text From One File To Another (overwriting Part Of The File)?

Apr 19, 2011

I have a .txt-file with ~50.000 lines of numbers, generated by a mathematics program. From this file, I need line ~ 1.100 to line ~16.000 (these lines are always the same btw, this may make the solution easier, dunno) to be copy/pasted to another file, where the lines ~500 to ~15.000 (also, every time the same) should be overwritten by the aforementioned lines...I haven't found or come up with anything that works yet, mostly I find solutions to copy everything from one file to another but I can't find something to specifically overwrite a part of a file with part of another.

View 4 Replies View Related

General :: Overwriting The Middle Of A File From A Block Device *without* Truncating File?

Jan 15, 2010

I have a Linux (Kubuntu) system with a large (~20Gb) file which I would like to mess with. Specifically, I want to copy the entire contents of another large file (~12Gb) to the middle of this file, and keep the bits of the file which are not overwritten.This is what I want to happen, with the text between the pipes representing file contents:Before:

outfile: |abcdefghijklmnopqrstuvwxyz|
infile: |123456789|
After:

[code]....

View 1 Replies View Related

Programming :: Overwriting Setting Due To How Close They Are In Name

Aug 16, 2010

I have a configuration file I put ndd commands into for servers settings and I'm running into and issue where they are only off by one character so I keep overwriting the setting.

The file has these two lines in it:

As you can see the only difference is the q0 on the one entry. With the code below I just keep changing/adding a line to the file and not just finding and fixing the each line. I cannot seem to find the right "terminator" for an exact match. I do understand why it's doing it, I just don't know what to do to fix it. What am I missing?

In the end I just want to search this file and make sure these two lines are in there and set properly.

View 3 Replies View Related

Programming :: Bash Script To Copy Without Overwriting?

Oct 21, 2010

i have one questions :"bash copy filename destin_dir"1- i need a bash script to copy file from one directory to another , and if the destination directory have the same file name, add '_1' to the file name ..and if there is a file with 'filename_1' , add '_2' to the file name and become 'filename_2' and so on

View 5 Replies View Related

Programming :: Gawk -- Print In A New Line Without Overwriting?

Sep 20, 2010

I have a directory where there are folders and in them some .txt data files. I am trying to output a .txt file with the folder name and the number of .txt files in it using gawk. However, when I run my shell program, because print is nested in a "while" loop, gawk overwrites what's already saved in the output file. I want gawk to print "new" output in a new line without overwriting the already existing text in the output fil

#! /bin/sh
# getting the folder list and the number of folders
ls | gawk '{print}' > ../folder_list.txt

[code]...

View 6 Replies View Related

Programming :: Python - How To Avoid Spaces

Oct 1, 2010

In the code below:

Code:

The output is:

Code:

Looks like the "," operator in the print inside the loop is adding a space for its own.

I want to print the sequence WITHOUT spaces. Something like this:

Code:

But I couldn't figure out how to do this.....

How to print a sequence, inside a loop, without that space ?

View 14 Replies View Related

Programming :: Avoid JNI In Order To Port A C/c++ STL Application To Android?

Jun 16, 2011

I wonder if it is possible to avoid JNI in order to port a c/c++ STL application to android ?Do I have an alternative for calling C/C++ (STL) code ?

View 2 Replies View Related

Programming :: Avoid Application From Closing If A Specific Library Not Found?

Jan 2, 2011

i was wondering if there is away to avoid application from closing if a specific library not found? for example: if my application uses libPng and it wasn't found on the system running my app (binary and not source), is there anyway to just disable the part that uses png from my application?

View 14 Replies View Related

Programming :: Finding G++ Compiler Option To Avoid Forward Declarations

Sep 23, 2010

I am working for a product which was evolved over a decade. There I have some combination of C style coding and C++ coding in same libraries. I am landing on some instances where C style function is expecting forward declarations for some other function for which I can not declare (due to design and architecture). Is there any g++ compiler option that directs the g++ to look whole preprocessed file (because definition is there down in the preprocessed file) than only forward in the preprocessed file. All these years this code is working as we are using CC compiler and that looks entire preprocessed file than only in the forward direction.

<Sample Code
Header1.h file
Function1()
{

[code]....

if I can not include Header2.h first then Header1.h. I have to include Header1.h and Header2.h because on the design hierarchy in this product. Also the function definitions are in header files as they are either template functions or functions expanded through macros.

View 6 Replies View Related

Ubuntu :: Avoid Users Writing On The Same File?

Feb 27, 2011

Is it possible to forbid that more then one user open the same file in rw mode? In windows when you open a file that another user is using, there's ad advise and you have to open it in read only mode

I installed ubuntu 10.04 desktop edition on 3 pc (there is not a server-client architecture). I installed samba.(and smbfs)

put the strings:
[name]
comment = ...
path = /...
guest ok = yes
read only = no
create mask = 0777
directory mask =0777

Computers that access to that directory do (on boot, with root privileges)
mount -t smbfs -o username="user",password="pass" //192.168.0.12/name /mnt/cartelladimontaggio

But if two users access to the same file, both are authorized writing on it! So changes made by one are lost when the other save.

View 4 Replies View Related

General :: Overwriting A Given File With "0"

Oct 5, 2010

I want to overwrite a set of files with the character "0" in order to delete their contents. For individual files I can do -

Code:

However for multiple files in a particular directory if I try the following -

Code:

The files are not getting overwritten.

View 4 Replies View Related

Security :: Folder Permissions To Avoid File Upload By Http User?

Feb 24, 2011

However, configured a website on a dedicated server using WHM/cPanel. The site was uploaded using the master account for the website.

The security issue is public users are able to upload files on to my server via the website. They could even access the root and execute whatever they want on the server.

I have consulted with 2-3 Linux experts. According to them, the PHP user has rights to execute anything on the server or upload & store files in whichever folder they want.

Can I protect my folders to avoid file uploads via the website. The application has security vulnerabilites. However, I want to prevent hackers to enter my site until the vulnerabilities are fixed.

View 2 Replies View Related

General :: Vim - Avoid Changing A File's Linux Permissions When Saving Over A Samba Connection?

May 28, 2011

I have an Ubuntu development server and a Windows 7 workstation. I use Windows Gvim to edit files on the linux server, over a samba connection.Saving files from Windows change the Linux permissions in weird way depending on the Windows app I'm using and also depending on whether there's a file extension or not.Here are some testsNo extension; Notepad2: 644 to 764

matt@mattserver ~ % ls -l testfile
-rw-r--r-- 1 matt matt 0 2011-05-28 07:09 testfile
--- Save from Windows Notepad2 over network ---

[code]....

View 1 Replies View Related

Server :: Cp And Mv Without Overwriting ?

Apr 20, 2011

I want to create an alias or shell script (I use bash and ksh at work) that will work like mv -bf but instead of adding a ~ I want to add a date time stamp. So if I move a file like greg.txt into a directory that already has a greg.txt it will rename or copy it to greg.txt.date-time. I want this to be pretty global, seemless, and *automatic*. I am familiar with 'no clobber' and it doesn't meet the requirements.

View 3 Replies View Related

General :: Hoe To Copy Without Overwriting

Oct 5, 2010

I looked in the man cp pages to find an option that allows me to copy files without overwriting and without having to answer no every time prompted (huge number of files) but i didn't find any.

View 5 Replies View Related

Ubuntu :: Overwriting Files Through FTP Using Nautlius?

Mar 27, 2010

I am experiencing a bug when overwriting files on FTP servers using the default nautilus FTP client.When I upload a file to replace an existing file via FTP, after I confirm the prompt asking me to overwrite, the content of the newly uploaded file is appended to the existing file's contents. The resulting file contains the content from both files. In order to fix this bug, I am forced to delete the existing file before uploading the new file.If I upload the same file multiple times, the error will continue to occur and append the new file to the existing file.

View 1 Replies View Related

Red Hat / Fedora :: Overwriting Encrypted Partition?

Feb 19, 2011

Somehow my file encryption password changed so when I went to re-install Fedora it said SDA-2 will not be available during installation.Is there a way to erase the whole disk including the ecrypted portion?

View 2 Replies View Related

Debian :: Installing Win 98 On Seperate Partition - Or Overwriting Deb

Apr 21, 2011

Well i have Debian on, and have been using Wine to use some windows applications, unfortunately the 2 main games i wanted to use don't work on it, and a variety of other applications don't work either. XP is a bit intensive for my laptop, so even though i own it, i can't install it. I wanted to install Windows 98 to my laptop, but there are some issues, and i have no idea how to get around them.

1. My laptop has no CD/DVD drive (has one but doesn't seem to read any disk), it has no floppy drives, and the BIOS does not support booting from USB.

2. When trying to create a seperate partition on my HDD with linux on to try and make room for Windows, it stops me saying the drive is busy.

Specs:
2.8GHZ Pentium 4
ATI Radeon Mobility 7000 IGP 32MB Shared memory
256MB of RAM (217MB due to shared memory)
40GB HDD
2GB USB Storage Device which currently has Windows 98 SE setup files on it.

Has an internet connection via ethernet cable to my brothers laptop. Also have GRUB installed, asks me which OS to boot. Debian Squeeze.

Ideally i wanted to wipe debian off, as its putting my laptop under a bit of strain and can't run what i want it too, or if thats not possible, just split the HDD in 2 and have Windows 98 as my main OS.

View 3 Replies View Related

General :: Dhclient Overwriting Resolv.conf?

May 30, 2011

I'm setting up virtual dev environments and I want the hostname.domain to be something specific, eg- "barney.local". However my /etc/resolv.conf file keeps getting nuked because i'm using DHCP. I placed this into my dhclient.conf:

supersede domain-name "localhost"
supersede host-name "barney"

but it didn't help. I'm not sure where I'm going wrong. How can I still use DHCP but configure that virtual environment to see itself as barney.local?

View 2 Replies View Related

Software :: Rsync Keeps Overwriting Some Unmodified Files?

Jan 7, 2010

'm having this strange problem with rsync. I'm trying to synchronize my music collection with the music collection on my mp3 player (Cowon iAUDIO). The mp3 player has a harddisk with the FAT32 file system. The problem is that it keeps overwriting unmodified files on the mp3 player.I use this command to synchronize:

Code:
rsync -avhpu --delete --progress --exclude-from "/home/serrano/backup-filters-iaudio.txt" "/windows/D/music/" "/media/IAUDIO/music/"

[code]...

View 4 Replies View Related

Ubuntu :: Install 10.04 On A Second Partition Without Overwriting The Windows7 Bootloader

Jun 9, 2010

Is it possible to install ubuntu 10.04 on a second partition without overwriting the windows7 bootloader and boot it using grub on a usb stick?

I would be happy with just the second option as I could fix mbr if I have to, I just don't want it to easily visible that linux is installed as well as windows.

View 4 Replies View Related

Software :: Bacula And Overwriting The Data On The Next Backup On The Tape

Feb 22, 2010

Currently I have bacula backing up the contents of my server on a daily basis (Mon-Fri) on to a tape. There are in total 9 backup tapes so far. One for each day of the week (Mon-Thurs) and one for every Friday in the month (so there are 5 friday tapes). The tapes are all from the same pool and once the tapes are full they should then get recycled. As I understand and from what I have seen, the data from my server backups up to the tape and is then marked with the append status. Every time that tape is used, data is then appended onto the tape until the tape is full. At this point it is marked as full but wont be recycled until all the tapes from the pool are marked as full (so until all 9 tapes are full).

My question is, is there a way of overwriting the data on the next backup on the tape, rather than appending or requiring that all tapes in a pool are full before a tape can be recycled. As the mon-thurs tapes currently cant be recycled until all the Friday tapes have been used. The reason why I dont have seperate pools for the Friday backups and the other days of the week or even seperate pools for each day of the week, is that if a tape is accidently not changed or someone puts in the incorrect tape by accident a backup will still occur. Which is better than no backup!

View 2 Replies View Related

Fedora :: Method To Prevent Grub Installer From Overwriting MBR Pointer

Jun 17, 2010

Is there a method to prevent the grub installer from overwriting the MBR pointer when grub or the kernel is updated? I'm running a multiboot system and when Fedora's grub installs, then OpenSolaris' partition isn't included in the bootlist and Ubuntu's menu line has a chainloader line that doesn't resolve correctly, requiring a hand edit.I may try to do a chmod 444 grub-install , but I'm not so sure what the reprocussions may be.

View 9 Replies View Related

General :: Overwriting Specific Files In Directory Tree Recursively

Jul 19, 2011

I would like to overwrite files in a directory tree, recursively. The ones I would like to overwrite match the filename "x_alpha*.png" and have a size exactly 456 bytes. Is there any way to search for these recursively in a directory tree, and overwrite them with a reference file, for example "e:mydirgood.png"

I am using Windows 7, but I have UnxUtils, so I can use those too. What I am looking for is something like this, generated automatically:
copy /y e:mydirgood.png e:mydiracx_alpha0023.png
copy /y e:mydirgood.png e:mydirefgx_alpha0045.png
copy /y e:mydirgood.png e:mydirhx_alpha0248.png

View 2 Replies View Related

Ubuntu Networking :: Stop Wvdial From Overwriting /etc/resolv.conf?

Mar 3, 2010

I use wvdial and a 3G modem to connect to the network. On the same host I also run bind9 which is authorative for my local network.The problem is that when wvdial connects, it overwrites /etc/resolv.conf, which means that DNS lookups on that host no longer get made to localhost (as specified by the original resolv.conf file) and end up at the local instance of bind which is authorative for in-house hostnames, but end up with the ISP who doesn't know my in-house host names.The local DNS forwards to the ISP, so the ISP's DNS'es are not required in resolv.conf.How can I prevent wvdial from overwriting /etc/resolv.conf?Removing write privileges from /etc/resolv.conf did not work.

View 3 Replies View Related

OpenSUSE Install :: Dual-booting Ubuntu - Versions Of Grub Overwriting ?

Dec 9, 2009

I'm wondering how I would go about dual-booting Ubuntu with openSUSE installed first?

I'm just a little bit concerned about the versions of Grub overwriting the openSUSE version or theme or something.

Would it work okay if I just shrink my openSUSE partition and then set the Ubuntu installer to install Ubuntu to the free space only or do I need to edit the grub file and stuff?

View 3 Replies View Related

Fedora Installation :: Make A Dual Boot System (Vista And Linus) By Overwriting The Previous Suse?

Jun 26, 2009

I actually have a Suse running on a partitioned harddisk of 27GB but I prefer Fedore anyway. I would like to install Linus Fedora on my computer to make a dual boot system (Vista and Linus) by overwriting the previous Suse. My question is

Will I be in OS booting trouble (i.e unable to resurect the previous boot screens, windows might possibly be deleted, or not be present in the boot options) if this is done ?

Also, because I have only one disk (the first disk of Fedora 11 downloaded), will it be fine with just one first disk ? (there are several to download but I think I assume I am not going to use all of them during installation, right ?)

View 6 Replies View Related

Programming :: Socket Programming While Displaying Received Message In File

May 11, 2011

i have problem in socket programming, while displaying received message in file,i got a problem... i cant able to write it in the file.... this is the code....

Code:
/* tcpserver.c */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
[Code]....

now my problem is run time error i can able to create file but i cant able to write file....log.txt contain nothing.... as here i have give sample code... dont say not initialising function and all.... i have initialised , please only see func1() - my problem is only not able to write msg which i got received from the client..

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved