Programming :: In Correct File Is Empty?

Jun 17, 2010

I am using embedded Linux. File open is successful. The file has all the permissions. It is present in current directory too. The size is about 27KB. But s.st_size says it is zero.

inputFileName = "abc.mp3";
FILE* inFile = NULL;
inFile = fopen(inputFileName, "r+b");

[code]...

View 2 Replies


ADVERTISEMENT

Programming :: Bash There Will Be Empty Lines At The End Of The File?

Mar 26, 2011

Using awk I pull the first field of a random line from my datafile.myvar1=`awk -F" " 'NR=='$randline' {printf "%s", $1}' myfileThis works fine. The problem is there will be empty lines at the end of the file. Rather than using awkto filter out blank lines I would like to figure this out first.So I test $myvar1 for a blank string after setting $randline to one that I know is blank:test -z "$myvar1" && echo "true" || echo "false"But, this returns "false"? So the string is not zero length. Why? It's a tab-separated file. Is awk storing the tab with the $1 field or something.This is where I get headache. I try to echo my variable to see what it looks like.

echo "$myvar1"
outputs: nothing
echo "My variable is [$myvar1]"
outputs: [y variable is [

Why is the closing bracket at the beginning? What character could be stored in $myvar1 that would do such a thing and how did it get there?

View 7 Replies View Related

General :: Shell Scripting \ (test If A File Is Empty, If It Is Then Display "file Is Empty" Otherwise Display "file Is Not Empty")?

Oct 5, 2010

I am a final year student doign Computer systems engineering and just been introduced to linux. While still strugling to catch up with the commands, I am now given an assignment under shell scripting.I seriously am strugling to understand this question, can you please assist me.Here follows the assignment:

Operating Systems III
Some tips
e.g. (test if a file is empty, if it is then display "file is empty" otherwise display

[code]....

View 10 Replies View Related

OpenSUSE :: Empty The /tmp File Or Other File To Free Up Space?

Mar 23, 2010

I've noticed that when I run:

davek@linux-kw2x:~> df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 20641788 8427780 11165368 44% /
udev 961204 192 961012 1% /dev
/dev/sda3 217642344 4037944 202548468 2% /home
davek@linux-kw2x:~>

I have 44% used. It should be much smaller, under 10%. How do I empty the /tmp file or other file to free up space?

View 9 Replies View Related

Programming :: Delete Folder Not Empty C++?

Dec 5, 2009

I'm using rmdir(), and everything goes ok if the directory is empty, ?how can I remove the entire tree when i have other files or directories in the folder that I want to delete?I've read about using "system(rm....)" but i REALLY want to do this without it, is it possible?

View 4 Replies View Related

Programming :: How To Check For Empty Variables In PHP

Apr 26, 2010

I want to check if a MySQL db query will return an empty result - I first do this:

$query="SELECT * from <whatever" ;
$result=mysql_query($query) ;
$row=mysql_fetch_row($result) ;

Now how do I check if $row is empty or not? Will $row="" do the trick?

View 2 Replies View Related

Programming :: Check If Buffer Is Empty In C?

Apr 12, 2011

Greetings EveryOne

how to check if buffer is empty in c?

View 14 Replies View Related

Programming :: Set The Record Separator To An Empty String?

May 4, 2010

I tried to find out how awk works with multiline strings. I found this. I hope it will be useful for somebody. 1. I know that awk can searches simple patterns like '/^one/'

Code:
s="one
two
three"
echo $s | awk '/^one/'

2. I know that "Awk can handle multiline records by specifying the field separator to be a newline and set the record separator to an empty string." I've found it here

[Code]....

View 9 Replies View Related

Programming :: HOSTNAME Variable Is Being An Empty String

May 19, 2011

The script produces 2 empty lines and I don't know why.

View 1 Replies View Related

Programming :: Check If An Array Is Empty In Perl?

Nov 28, 2008

To do this, can I do this?:

if (@ary = ""),

or is something more needed?

View 4 Replies View Related

Programming :: Use If Else Condition When Returns Empty Data?

Apr 27, 2010

Let say I would like to check /etc/profile whether defined umask 022

umaskcheck=$(What to defined here?)
if [ What to define here? ]
then

[code]....

View 2 Replies View Related

Programming :: Javascript To Verify Correct URL?

May 31, 2011

Lets say I have a site "Website1.com"

On that site I want to run a little javascript that verifies that the site was accessed as "Website1.com" and not "dev-Website1.com"

If it was accessed correctly, nothing happens. If it was accessed incorrectly, it displays an error saying "You are trying to access this site incorrectly."

What is the simplest way to accomplish this?

View 1 Replies View Related

General :: How To Empty A File

Jul 15, 2010

I have a large file that a process writes to. I would like to empty that file. If I delete it the process will stop writing to it. Just flush the content but keep the file.

View 9 Replies View Related

Programming :: Listing Sudo Users - Getting Empty Space In Between

May 20, 2010

I was trying to list sudo users in a Linux Machine,

[root@redhat ~]# grep -v -E '^#' /etc/sudoers
root ALL=(ALL) ALL
%work ALL=(ALL) ALL
%dilipvp ALL=(ALL) ALL

where work is a group and dilipvp is user. Can you help me in creating a better script which can list the members of the group work as well. and why I am getting empty space in between.

View 6 Replies View Related

Programming :: Atoi() Not Giving Correct Answer?

Jun 20, 2010

i m using atoi() to convert char value to int. and then passing that int as a swtich variable.switch goes in a case and exectuing that particualr function but returning 0 value....for example: i am finding no of process() and system up time().when switch program goes in system up time it gives right values means correct no of days, hrs , min and sec but when it goes in no of process() it gives 0 answer.

View 8 Replies View Related

Programming :: Correct Way Of Spawning Parallel Jobs?

Mar 18, 2010

I need to spawn 2 processes in parallel and each takes an hour or so to finish. Is the following one of the correct ways of using `at` in a script run by crontab?

Code:
#!/bin/bash
# define the env var, cd, etc... assume everything ok up to this point
date +"The start time is %H:%M:%S"
rm -f a.fin
at now <<END_OF_AT
do_a &> a.log

[Code]....

View 2 Replies View Related

Programming :: Expect/TCL - Unable To Get The Correct Results

Feb 8, 2011

I'll post the entire code here, and then specifically highlight what is just failing in a fashion I'm apparently incapable of fixing a few hours later:

Code:

#!/usr/bin/expect
# The script should be called with a file in the directory called sshServerList
# That file has the following format:
# Line # | Contents of line

[code]....

I've had all kinds of different results and problems, but I've never been able to successfully log into multiple servers, though the first server in the list most times works okay (though might not on this iteration). I'm a bit hack and slash and I would be very greatful not only for a solution, but any tips on how I should have done this and places where I could clean up my code.

View 1 Replies View Related

Programming :: Bash Script To Correct The Filenames

Apr 11, 2011

I have a directory that has a bunch of files and directories under it that I need to correct the filenames of. In fact, I plan on running this as a cronjob to keep checking filenames for certain characters. I want directories and filenames with spaces or pluses (+) to have those certain characters replaced with underscores (_). I know that this will involve sed but I'm not sure what else. A simple shell script would handle it.

View 1 Replies View Related

Programming :: Not Getting Right Output To Correct Terminal Window

Jun 17, 2010

I have a server client prog in which server is my 'agent' and client is 'manager'. Following is the code for both agent and manager. I want my agent to send what manager is requesting. But it is not working the way I want. The parameters which manager is requesting, agent has to send to manager but in this program result for those parameters is shown on agent's own terminal window. Where as I want them on manager's window. Secondly, there result is not correct, means it is giving ' 0 K ram and 0 no of process....

Code:
//code for MANAGER
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h> .....

View 2 Replies View Related

Programming :: Sudoku - Calculate The Correct Box For A Given Square?

Apr 8, 2011

Im doing a sudoku-solver as a school assigment in Java. It is supposed to solve both 6x6, 9x9 and 12x12 boards.Im pretty much done with my algorithm(brute force), but I'm having a hard time figuring out how to calculate the right Box for a Square. I found this snippet:

Code:

// calculate BoardPos for index, where index is 0..80
void loadBoardPosFromIndex(BoardPos &pos, int index) {
pos.index = index;

[code]...

This works on 9x9 boards, but I really dont get the math behind this, and how I can create a generic rule for both 6x6, 9x9 and 12x12 boards.

View 4 Replies View Related

Programming :: Wcslen / _tcslen Not Returning Correct Value?

Feb 12, 2010

I have having some trouble working with wide characters, which is,

Sample code:
TCHAR fname[512];
_tcslcpy(fname, L"/root/Desktop/all/TheGrandTunnels.fgc", 512);

[code]...

View 4 Replies View Related

OpenSUSE :: Cannot Remove Empty File?

Mar 2, 2011

I was copying an .avi file to an external hard drive and half way through the copy the drive reset and required remounting. Consequently I have an empty .avi file on the hard drive. I tried to recopy the file and overwrite, but I keep getting 'Could not write to media/harddrive/filename.avi'. I tried to rename to file to be copied but got the same response, I cannot delete the empty file either, as I get an error telling I cannot delete it. I have tried to do this as the user and root with the same result.Any other file I tried to copy onto the external hard drive is fine, just this one zero length file and the file I was trying to copy, the original of the file. I also tried to delete the file on another computer but couldn'tExternal hard drive is a WD elements ntfs, which works great except for this glitch.

View 3 Replies View Related

Ubuntu :: Sed Command Empty The File?

Mar 13, 2010

I have this file: 1.txt, with this contents:

Code:
test
mycomputer

I just try change the string "mycomp*" by "othercomputer":

Code:
sed 's/mycomp.*$/othercomputer/' 1.txt > 1.txt
but sed command empty the file.

[Code].....

View 2 Replies View Related

Server :: The Boot.log File Is Empty?

Feb 28, 2010

Does anybody know why isn�t anything on the /var/log/boot.log file. After the boot I saw some services that fail to load and looking for more detail data on the boot.log file I couldn�t found anything this file is empty. This is My syslog.conf file:

Code:
kern.* /dev/console
*.info;mail.none;authpriv.none;cron.none /var/log/messages

[code]...

View 3 Replies View Related

Programming :: Correct Package To Install Javadoc On Fedora?

Nov 2, 2010

Anyone knows what is the correct package to install javadoc on Fedora???

View 3 Replies View Related

Programming :: Simple Bash Script Not Returning Correct Value?

Sep 14, 2010

I have a very simple bash script:echo -n Create home directory?:

read HOMEDIR
if [ $homedir="y" ] || [ $homedir="yes" ]; then
homeval=" --makehomedir"

[code]...

View 6 Replies View Related

Ubuntu :: Syslog.conf Empty File

Mar 15, 2010

I was checking my syslog.conf file recently and it seems that it is an empty file >_> it shouldn't be correct?

View 2 Replies View Related

Fedora :: Yum And Comps File Is Empty/damaged?

Dec 2, 2010

I have setup a local repository containing several .rpm files. I created a comps.xml file outlining the category and groups for the local repository. However, when I issue the yum grouplist command, I get the following error:

Failed to add groups file for repository: localRepo - comps file is empty/damaged

However, if I try to install one of the the packages in the repository, it works just fine.

Here are the steps I took to create the repodata:

The comps.xml and repository are stored in the directory:
/var/www/html/myrepo/x86_64
cd /var/www/html/myrepo/x86_64
createrepo -g comps.xml .

[Code]....

View 1 Replies View Related

General :: Create Empty Or Blank Iso File?

Nov 23, 2010

I having been searching for a way to create an empty or blank iso file, so that I can mount it, and have a backup application think it's a blank CD. I am tired of wasting CD's by having the application write a recovery CD, just for me to turn around and export it to an iso image to be stored in a online archive, and then throw away the physical CD.

View 5 Replies View Related

Server :: Empty PID File While Starting Script?

Aug 16, 2010

I'm trying to write shell script to use etc/init.d In fact, my application has written by java and I have made the fat.jar (etest.jar)file as executable one and after I wrote the small script to run it background (etestruner.sh) that is,

Code:

#!/bin/sh
java -jar /root/les/run/etest.jar >/opt/etstout.out 2>&1 &

And after I wrote the service script That is ,

Code:

#!/bin/sh
#
# Startup script for epict
#
# chkconfig: 2345 25 88

[code]....

I tried with google to solve this issue but did not get any result.

View 3 Replies View Related







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