Programming :: Make Getchar() Skip A Leading Space?

Jul 10, 2010

How do I make getchar() skip a leading space? The situation I am looking is this: I print a prompt that ends in a space printf("Input: ");and then when I use getchar() to read the text that was typed after the prompt, it appears to process the trailing space as a leading space that belongs to the input.

how can the space be skipped, preferably without inserting code that explicitly checks whether I'm reading the first character or not. I have already found out that I can skip such a space using scanf scanf (" %c", &ch); where the leading space in the format string eliminates leading spaces from the input string. That is the sort of thing I have in mind.

View 7 Replies


ADVERTISEMENT

Programming :: How To Skip Getchar In C

Oct 1, 2010

I would like to read an input from keyboard using getchar. However, if no input (No Carriage return/new line none whatsoever) is given after say, 5 seconds, I would like to skip the getchar and move on. How do I do this in C. I'm using GNU compiler set.

View 6 Replies View Related

Programming :: Bash Scripting: How To Keep Leading 0 On ' And '

Jan 27, 2010

I'm trying to put together a script that will quickly run through an archive directory of log files that are named by day of the month 01.gz, 02.gz, 03.gz.... 31.gz. The script uses gunzip -c | grep | wc to count up the total number of hourly occurrences of a filename and outputs the results to stdout.

The only snag I have left is the octal limit when it gets to 08 and 09. I've seen examples using perl and awk, but this script uses a number of nested for loops and if statements that I don't want to have to rewrite in a different syntax. I found that I can use num=10#08 to set that variable to a base 10 instead of a base 8, but then I lose the leading 0 again when it passes the number to the next filename variable.

View 8 Replies View Related

Programming :: Sed Insert Line With Leading Spaces?

Mar 3, 2011

I'm trying to insert a line using sed that has leading spaces before the text. Sed seems to be just dropping the spaces and only inserting the text. Any ideas what I'm missing?

Code:

NAM=rb134
sed -i.bak -e "$i
host ${NAM} {" /etc/crap

Instead of inserting a line with 8 leading spaces inserts it with "host" at the beginning of the line. I tried

Code:

NAM=rb134
sed -i.bak -e "$i
^ host ${NAM} {" /etc/crap

but it put the "^" at the begging of the line.

View 6 Replies View Related

Programming :: Make A (user Space )process Pre Emptive / In 2.6 Kernel?

Dec 10, 2008

I am writing a program which i dont want the kernel scheduler to preempt before certain time duration. I am using the system call sched_get_priority_max to set the maximum priority. However it is not producing results.

View 3 Replies View Related

Programming :: Bash Script Trying To Remove A Leading 'and A Tailing'?

Mar 28, 2010

I have a script that calls for a file description on a core file. I then pull the name of the process that caused the core file.
unfortunately, the process name is pulled with a leading ' amd a tailing'. I would like to remove the leading char and the last char.

code:

VAR=`file /tmp/core.1432 | awk '{ print $14}'`
echo "Process Name: $VAR"

output:

Process Name: 'ProcessName'

Results I need:

Process Name: ProcessName

I tried sed, but it seems to not like using the special char '.

View 14 Replies View Related

Ubuntu :: Make A Script That Will Skip The Screen Saver Stage And Just Shut The Monitor Off?

Jul 23, 2010

I am trying to make a script that will skip the screen saver stage and just shut the monitor off (and not come on till the computer is touched)

Code:
#!/bin/sh
gnome-screensaver-command --lock
xset dpms force off
gnome-screensaver-command --inhibit
exit

that appears to work but i want it to exit after the computer is touched again

View 5 Replies View Related

Programming :: C- How To Skip Dirs That Are Mounted Twice

Aug 27, 2010

I need to list a directory recursively but I want to skip subdirs that were already mounted. There are 2 cases:

a) a filesystem was mounted twice, like in this example:

- "/dev/sda2" was mounted on "/mnt/mnt_point1"
- "/dev/sda2" was mounted on "/mnt/mnt_point2"

I want to list "/mnt" but descend only in "/mnt/mnt_point1"

b) part of the file hierarchy was remounted somewhere else, with "mount --bind":

- "mount --bind /home/user/tmp/test /home/user/tmp/mounted_test"

I want to list "/home/user/tmp" but descend only in "test" "statfs" and "statvfs" don't offer any information to discern if a dir was mounted twice. One solution would be to read "/etc/mtab" (as "find" command does it) and perform some checks, but I think that this is pretty expensive (one has to read /etc/mtab every time one encounters a dir; if this file is read only when program starts, a mount could occur in between reads, so that the program will be inaccurate). Another solution would be to filter kernel events (via libudev or Netlink) and do this reading of /etc/mtab only when a MOUNT event was issued.

View 1 Replies View Related

Programming :: Making The Mplayer To Skip Some Files?

Jun 6, 2010

GNU/Linux kernel 2.6, Slackware 12.0
MPlayer 1.0rc2-4.1.2
GNU Bash 3.1.17

I've got a set of MP3 files on dir .../foo/ and I want mplayer to play them sequencely but skipping some of them. If I run 'mplayer *' this will do but ofcourse won't skip any files. I think a shell script could be written to do that. It would be something like this (using some pseudocode):

#!/bin/bash
#After an example from Intro_Linux by M. Garret.
LIST=$(ls *.mp3)

[code]....

View 3 Replies View Related

Programming :: Skip Execution Of A Function In A Script?

Mar 15, 2011

I have a bash script which is composed of different functions.I want to able to select which functions to be executed when i run the script, for that i thought about using a flag in the function. but i dont know how to skip the function whose flag is set to zero.

Code:

myfunc1(){
local flag=1
commands
{

[code]....

View 2 Replies View Related

Software :: Make Iconv To Skip Incorrect Symbols Or Iconv Alternative?

Jul 24, 2011

I'm going to convert a lot of text files from unicode to MS Win encoding cp-1251 but I fail using iconv since it stop converting when reach a symbol not existing in Windows codepage:Code:iconv: illegal input sequence at position ...Is there a way to force iconv to continue encoding skipping incorrect symbol or any other program for CLI codepage conversion? I'm remember there was a 'konvert' command many years ago in one (and as far as I remember it was not stopping in this case) but I can't find any package providing this command...

View 3 Replies View Related

Programming :: Passing Data Between Kernel Space To User Space In Asynchronous Way

Dec 13, 2010

I am developing a I2C CDROM client driver. The CDROM firmware supports TOC information read through a I2C command. It sends the TOC information in burst ( Interrupts a GPIO pin when it is ready ) and my CPU does a I2C read to read the TOC. When the CDROM firmware finishes sending the last data burst , it informs my CPU that it is done with the TOC, by a flag in the last data burst. I would like to know, which is the most efficinet way I can send these TOC information to userspace?

View 4 Replies View Related

Programming :: Function In Kernel Space Called Form User Space

Jul 7, 2009

I wanna write a file in kernel space but from my searching I can to know that instead of writeing file in kernel space ,I can write data to user space by copy_to_user space.

But link is missing ...I dont know how will my user space will access kernel space means my function in kernel space which will do copy_to_user /....How my user space function will call my kernel level function ..

Can any one of you provide me with some example file which are doing this .I know every char driver is using it ...but i could not trace back how user level function is accessing it ...i m confused between user space and kernel space.

View 2 Replies View Related

Programming :: Call Socket Prog Code Written In User Space From Kernel Space?

Jul 14, 2009

How to use execv from kernel space to call a user space program writtenfor socket prog.

I tried to write code for socket in kernel but its not working.

Socket code in kernel is also needed.

View 2 Replies View Related

Programming :: Signal From Kernel Space To User Space?

Jul 21, 2011

I have the following requirement in my module. The driver gets some data from the external device. After getting 1MB of data it has to send it to the user space application. What is the best thing to implement for this in driver.? Is it ok to implement like, after getting data, the driver will send a signal to the user space application. Then the user space application sends an ioctl to read the data. Is there any alternate, that the driver directly sends the data without the user space application asks for it.?

View 4 Replies View Related

Debian :: Make Tmp And /home Use The Same HDD Space?

Aug 28, 2011

Can I make my /tmp and /home use the same HDD space instead of having everything under / except for /home use the same space? I chose to only have two partitions: / and /home and that is what I want

View 3 Replies View Related

Programming :: Makefile - Error When Run The Make Run - No Rule To Make Target - Shell.h

Sep 15, 2010

I want to gave much details as possible. working directory (~/a1/shell) in the shell directory i have Makefile. also in the shell directory i have subdirectory's (obj, src, include)

My current Makefile

Quote:

#What needs to be built to make all files and dependencies

clean:

# End of Makefile

I wanted it so: all .o files are created in the obj subdirectory, and my application, sshell, is created in the shell directory.

I am getting this error when i run the make run: No rule to make target 'shell.h', needed by 'shutil.o'. stop

View 1 Replies View Related

Ubuntu :: Make A Background Set Like The Space Pictures Set In Karmic?

Jan 22, 2010

I like the background set in Karmic with the space pictures--it rotates the background every so often. How do I make a set like that with my own pictures?

View 2 Replies View Related

Ubuntu :: How To Make Partition Out Of 50GB Free Space

Jul 2, 2010

I'm relatively new to ubuntu. I want to run ubuntu alongside my windows partition. I have shrunk the volume that leaves me 50 gb of free space for ubuntu. Will the system automatically set the system and mount volume sizes? If not can I have some tips on manually using the 50 gb to set it up.

View 1 Replies View Related

Ubuntu Installation :: How To Make LiveCD Of 700MB Space

Oct 23, 2010

I want to make a live CD for ubuntu, but upon getting the .ISO I found that the .ISO was 709MB, and my disc is 700MB. How could I precede in making this live CD? If I use some sort of over burning software, will the live CD work, and please recommend a software to do so if it does indeed work.

View 8 Replies View Related

General :: Which Files Are Taking Space To Make The Partition 68% Used

Jun 8, 2011

I have some confusion about one of my partition and the space it is taking. df -h output is given below;

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ddf1_ADVDTARTINGp1
494G 18G 452G 4% /

[code]....

above information is showing that /var/lib/mysql partition total size is 379 GB and it is 68% used. However when I execute command du -sh /var/lib/mysql it shows following output.

# du -sh /var/lib/mysql
45G /var/lib/mysql

Now I want to know what files are taking space to make the partition 68% used. I want to list down all files in that partition with size.

View 8 Replies View Related

General :: Delete The Folders And Make Space To Continue

Aug 29, 2010

i have been copying dvd's and now i do not have enough room in my temporary folder,but i cannot find out how to delete the folders and make space to continue

View 7 Replies View Related

General :: Division Of Logical Memory Space In To User Space And Kernel Space

Jan 4, 2010

Logical Memory Space of 4GB is divided in to 3GB User Space and 1GB Kernel Space. Always. Correct?

1. How can we change it? (just changing value of PAGE_OFFSET is okay?)

2. If system have only 256MB of memory (embedded system) and suppose Kernel Modules eat away all the memory during boot. User space will be left will no memory. Is this case possible?

View 2 Replies View Related

Ubuntu :: Managed To Shrink The Windows Partition To Make Space?

Oct 10, 2010

I recently installed ubuntu alongside windows 7 on my machine. I ardly know anything about partitions, but I managed to shrink the windows partition to make space, abd then use the ubuntu installer to create the ubuntu partition. But I hadn't realized that there were actually 3 Windows partitions - "Acer C:", "Recovery", and "System, Active, Primary Partition".

So I didn't know that I should have made the ubuntu partition "Extended", which means that I can't make new partitions anymore. Is there anything I can do without reinstalling ubuntu?

View 9 Replies View Related

Ubuntu Installation :: Cannot Make Enough Space / No Root File System?

Jun 27, 2011

I've been trying to install ubuntu 11.04 64 bit on a partition next o windows 7 64 bit.When I use the default option (no matter how large I make the partition) I get the error message that not enough space could be created. I read this could e solved by defragmenting the hard drive which I did, but the problem persists.I next tried to partition manually but go the error message that there was "No root file system is de or something similar

View 4 Replies View Related

Ubuntu :: Conky Countdown With Leading Zeroes?

Jun 5, 2010

I found a script that counts down to a date and time and after modifying my .conkyrc file I want things to line up nicely, so, now I need leading zeroes on the output, like one timer I have says "4m +2w 5d 20:0:0" and I want it to say "04m 02w 05d 20:00:00" and on a slightly separate issue, it doesn't seem to be counting the minutes and seconds correctly, but that can be dealt with later, the current script is

Code:

#!/usr/bin/perl
#Script Name: howLong.pl
#Author: Nathan Handler <nhandler @ubuntu.com>

[code]...

View 9 Replies View Related

Ubuntu :: Bash Completion With Leading Wildcard?

Jul 17, 2010

Out of the box, Bash in 10.04 is configured such that it won't expand/complete parameters when there's a single match for a parameter with a leading wildcard. For example, if I have the following files in a directory:

Code:

ABC.bin
DEF.bin
GHI.bin

...and I type cp *E*, I expect to be able to press TAB and have Bash expand *E* to DEF.bin, since that's the only file in the directory with a capital E in its name.

(Note: if I actually submit the command with the wildcards in place, the correct file will be used then, but I don't get to see it beforehand.) I imagine there's something in /etc/bash_completion that's preventing this from working properly. Does anyone know what it is?

View 1 Replies View Related

General :: Want To Make Linux Distro Occupy Previous Window OS Space

Jan 30, 2011

When I first started with Fedora I tried a dual boot situation to see if Fedora 13 was going to meet my needs. After being totally satisfied I deleted Windows from my computer. How can I get Fedora to also occupy all the disk space Windows once occupied? I have a 15 GB USB drive to work with if needed.

View 1 Replies View Related

Software :: Renaming Some Files (adding Leading Zeros)?

Jan 8, 2011

I need to rename some files. They are named:

NP1-1.mp3
NP1-2.mp3
NP1-3.mp3

[code]....

However, as there is no lead 0, the order gets confused by some software (some software mistakenly lists it as NP1-1.mp3, then NP1-10.mp3). I'd like to add zeros so the files are named like this:

NP1-0001.mp3
NP1-0002.mp3
NP1-0003.mp3

[code]...

How can that be done?

View 3 Replies View Related

OpenSUSE :: How To Get Rid Of White Space / Make Document Actual Real Legal Size

May 7, 2010

I scanned a document with xsane and saved it as a pdf, the pdf shows up great but there is extra white space at the bottom of the document. how do i get rid of the white space and make the document the actual real legal size?

View 2 Replies View Related







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