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.
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?
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
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
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.
I'm doing a script to make some task but I would like to know how can I do the part to check the bu.log ? Cause if the files exists it will send me an email with the log, but when the file doesnt exist it will send a blank emal that why i would like to 'check the file' and if there isnt will end it.
#!/bin/sh x="$HOME/bu.log" if [ $x ]; then #if the file exists will do for file in *.log
[Code].....
How can I edit the funcion to check if there isnt an arq.log and close the script?
I have spent quite a lot of time on this problem. It seems like the file is sometimes closed when reaching config(fd), but removing the usleep(a while) seems to remove the problem.
i've written a socket server. when i launch a client, it connects to servers running on various machines on my local network, which then reply to the client with some string messages, and the client exits.
however, when i launch the client repeatedly (say 5 or 6 times in quick succession) the client is unable to bind to its local port. this appears to be because servers are still trying to connect to the client machine's port, even though the client exited and shut the socket down. the actual error i receive is "Error binding socket to 192.168.1.6:44561: Address already in use".
so, is it enough just to shutdown and close a socket? is there some way that in doing so the client machine can send a CONNECTION_REFUSED message to any machine trying to connect to it? i am using PHP, not that that should make much of a difference i hope.
the problem resolves itself after around 20 seconds as the machines trying to connect to the client timeout. i still need to fix this issue though.
I am trying to get bash script using zentity to exit if the user presses the cancel or close buttons.The exit codes are working fine; they read 1 or 0 depending on the status but it always assumes 0. This is the portion of the script: PHP Code:
function settings(){ result=$(zenity --height=30 --width=300 --list --checklist --title='Selection'--column=Boxes --column=Selections --column="Options"
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.
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.
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.
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?
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.
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:
'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:
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.
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!
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.
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?)
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
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.
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?
reading through the documentation for pk2cmd, required for using the PICkit2 programmer. I aim to install using the source, and thus libusb-dev is needed. The docs says that the runtime is usually included with the distro but the dev-part is not. Well, to be on the safe side, I downloaded the source for libusb (0.1.12), which in turn should contain libusb-dev.One step down, a few more to go. pk2cmd should be pretty straightforward to compile, but ...
Now I am asked to set up USB so that it can be used by users other than root. A document is filled to the brim with instruction for cases old and new. It makes my head spin and that's why I am asking. The programmer shows up fine with lsusb,I see it as/dev/bus/usb/001/006So, basically, as I understand it, the device need the proper rights to be used by a regular user. But how do I do that?
I'm running into a problem when I try to set a variable to an awk output in c-shell. Right now my command is Code: set STR_MSG_TYPE = `awk -F{ '/msg_type/ {print $2}' <filename> | tr -d }'/''*' ` I then run echo to see what the output is and it returns blank, however, when I run the same awk command from the command line, I get an actual output of "MT-715". Am I setting my variable incorrectly? I do something similar using the date command to set a STR_DATE variable earlier in the code and it works fine and I use the same syntax.