Ubuntu :: Allow Empty Return From Read Command?
Feb 19, 2010I am writing a short script to do some backups.Here is a small section of it:
Code:
echo -n "Please enter your choice ..."
read CHOICE
[code]....
I am writing a short script to do some backups.Here is a small section of it:
Code:
echo -n "Please enter your choice ..."
read CHOICE
[code]....
I need to make a function combination to get for: If cell A1 then for B1 as:
A1 B1
--- ---
abc abc
hello hello
empty empty
0 0
-3 -3
5 5
and like wise
I have a text file have carriage return code ^L , ^K , I can use vi to read this code , can advise if I want to see this code , what can i do
View 4 Replies View RelatedI have a script that reads part of a line, delimited between the first and second intended part by a colon. Then it "chops" the part after the colon, which are words offset by commas (counting them beforehand so as to catch every word in the string's second part), like this:
Code:
"COLORS.JPG:red,orange,yellow,green,"
(Returning)
red
[code]....
single script that parses/breaks both parts of a line like this "COLORS.JPG:red,orange,yellow,green;blue,indigo,violet," so that the two parts, separated into single words (or two and three words, sometimes with spaces) can be used as single-line annotations and written to JPEG files using Exiv2. So far, I haven't been able to come up with a script that does this without one part of the total string(usually that part after the colon) becoming the first word in the second array. In other words, I look for this:
KEYWORDS:
[ ]red
[ ]orange
[ ]yellow
[code]....
Or vice-versa (ie, the second array winds up as a single-line "member" of the first). I think it's because I'm using a single while read loop to read the text file in which the filenames and substrings happen to be. If there's some way of reading a file once and going back to the beginning to read it again in another while loop, I haven't found it.
I am implementing a simple serial protocol where my ARM9 board, running Linux is communicating to a slave peripheral board. The Master sends a 12 byte data stream and the peripheral board returns status in a 23 byte response. The serial port is opened in raw mode. It works perfectly on 44 reads; however, on the 45 read the data returned from the read() is incorrect. I've framed what's being sent on an oscope and it is correct.The coincidence is that 23 x 44 = 1012. It's as though the receive buffer is 1K and when I go past the boundary I get bad data. The read following the bad one is good again.I've tried flushing the buffer before reading but get the same result.Here's the port initialization code:
Code:
int initport(int fd)
{
[code]...
Does anyone know why files in my /tmp directory are not able to rm even using root login? not only that, I can't even chmod or do anything to files in /tmp directory... it always saying "read only file system" warning
View 8 Replies View RelatedI'm trying to get a return value from the command running within screen. I have tried
Code:
screen "some_command ; echo $? > retval"
but this refuses to write "retval".
[code]....
I am testing the serial ports on a Single Board Computer(SBC) running Linux kernel 2.6.29. I usually do this by connecting the serial port to another PC serial port, then doing "cat /dev/ttyS0" on PC and "echo hello > /dev/ttyS0" on the SBC. However in the current system, "echo hello > /dev/ttyS0" command does not return at all! Also no characters appear on the destination port. I am running the echo command as root. The system boot messages show that the serial port in indeed /dev/ttyS0.
View 2 Replies View RelatedI 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].....
To put it simply I want the egrep command to return matches for a group rather than the whole pattern itself.For example:
Code:
egrep "reals([0-9]+?m[0-9]+?.[0-9]{3}s)" tmp
returns
"real 0m1.001s"
But I want it to return just "0m1.001s", the portion is the group. I can just apply egrep to whatever the first command returns but is there an easier way to do it?
What is a Linux command that I can run to programmatically return either 32 or 64 to indicate whether the processor is a 32 bit or 64 bit processor?
View 4 Replies View Relatedgetting a error return code for useradd commandthe return code is 1cite or tell me the explanation of return code 1 .
View 1 Replies View RelatedI need to get a return code for the command ldapmodify.I try this and didn't workrc=ldapmodify -a -v -c -p $PORT -h $SRV -D cn=$USR,cn=Users,dc=company,dc=com -w $PWD -f $LDIFFILENAMECOUNTecho "return code " $rc what exactly the way to get the return code of that ?
View 2 Replies View RelatedHow can I pass carriage return to a command. I am writing a shell script whcih generates ssh key pair. It ask for input from user three times. I want to pass carriage return (ie. press Enter button) to this command. Is tehre any way
View 8 Replies View RelatedI'm creating a usb device driver that needs to be able to read from two different endpoints. I couldn't see any way of having two read functions in the driver, so I got round this by reading from one of the endpoints with read, and the other with ioctl.However this hasn't worked, the ioctl call from c returns -1. I added a printk command in the driver in the ioctl function, however looking at kern.log I can see that this function is never being called. Does anyone have any ideas as to what the problem called be, or a better method of being able to read from two different endpoints?
View 2 Replies View RelatedBelow is an example output of what I see when I run the 'ls' command on some directories in linux (this is from a tomcat/common/lib directory). However I'm not clear on why some of the filenames are appearing inside [square brackets]
-rw-r--r-- 1 root root 1038825 Aug 30 2006 [ant].jar
-rw-r--r-- 1 root root 566376 Apr 1 2008 [commons-collections].jar
-rw-r--r-- 1 root root 107392 Aug 18 2006 [commons-dbcp].jar
[code]...
Normally one can start the Jboss with
Code:
./run.sh -c server-name
But in this way the command console will keep hang. Now I want to write a script which calls u this command and return back to the command console. Here is what I wrote but it doesn't return back to the command console:
Code:
#!/bin/sh
MSGBP_HOME="/opt/jboss/MSGBP"
case "$1" in
start)
[code]...
How can I pass carriage return to a command in the shell script. I am writing a shell script whcih generates ssh key pair. It ask for input from user three times. I want to pass carriage return (i.e., press Enter button) to this command.
View 2 Replies View RelatedI wrote a character device driver for an Embedded Linux build (Kernel Revision 2.6.17.1) running on ARM9. In the module's "read()" function, I'm returning the number of bytes that were copied into the user buffer. I saw some module code samples online and in most cases the "read()" function is returning the number of bytes read.The very strange behavior I saw in my case was, if I use a variable to return the value from the module's "read()" function, the user application reading from the module always saw "0".For instance:
Code:
static int zlg7289_read(struct file *file, char *buf, size_t count, loff_t *ppos)
{
[code]....
Simple question but even google does not come up with an answer, seems to be too easy that someone else asked it ;). Could anyone tell me what is the shell command to empty the garbage bin under Linux?
View 3 Replies View RelatedHow to manage the find command to return true or false if a file was found/or not? I tried to man find but didn't found anything.
View 12 Replies View RelatedI mount /home on a logical partition. Files and directories that I trash from here go nicely into the recycle bin, and I can right click on it and choose "Empty Trash" with no problem. Files off of the root directory in directories that I "own" (i.e. /mydir/*) do not play as nicely. I went ahead and followed instructions from another post, namely:
Code:
sudo mkdir /.Trash
sudo chmod 1777 /.Trash
And after trashing some files from /mydir, there is indeed a subdirectory with my uid (1000) and files that I trash from /mydir are going in there. However, the recycle bin on my desktop remains empty, and the only method I have for deleting said files is by deleting them from the /.Trash/1000 folders through the command line. So my question is: Is there anyway that I can trash files from /mydir, see them appear on the desktop recycle bin, and empty the trash without the need to rm them directly through the command line? Not sure if it will help, but here is my fstab:
Code:
# / was on /dev/sda1 during installation
UUID=4129f389-92be-459e-8bbc-928c1440f718 / ext4 errors=remount-ro 0 1
# /home was on /dev/sda6 during installation
UUID=6a30914d-04a3-4b03-85bd-2bf16a68a41a /home ext4 defaults 0 2
# swap was on /dev/sda5 during installation
UUID=f388cf04-bbd6-4bf9-9d69-0778b0f158fd none swap sw 0 0
I am looking for a way to delete the currently entered commandline without wasting seconds on the "Backspace"-key.
For example I scrolled the bash history and have a long commandline that would execute when I pressed ENTER:
~$ aptitude search openssl | grep dev
But now I decide that I do not want to execute this command. Can I get an empty prompt fast without deleting the whole line with Backspace? On the Windows "cmd" you can just press ESCAPE and it is gone. This behavior would be what I want.
The question may seem trivial but this is bothering me for a long time now.
Is there a command line option that will allow less to return to the command line if there are not sufficient lines in the file to warrant paging.
View 1 Replies View RelatedI logged into my Red Hat Enterprise Linux machine at work (use it for software development) and the primary GUI does not load. Instead, widgets appeared for xclock, xterm, and Firefox. In the terminal, I start typing in commands to try to figure out what's going on, but all commands are not found except pwd and echo. I 'echo $PATH' and that returns just an empty, blank line. 'echo $SHELL' lets me know I'm using cash.
The likely cause was my attempt to install Adobe Reader Firefox plugin yesterday. After it downloaded, I ran the binary but Firefox didn't seem to recognize that I had installed it, so I went into my .cshrc file and added the adobe folder to the path. That didn't seem to work, so I gave up, deleted the binary and the folder I installed to, and removed that directory from the path in the .cshrc file. This last thing (the export PATH line in that file) I'm certain is back exactly as it was before.
I have successfully added the /bin and /usr/bin back to the path from command line via
setenv PATH /usr/bin:/bin
but of course it doesn't stick after reboot nor does it magically load the primary GUI. I'd rather not go through the effort of creating a ticket for our company's Global Service Desk cuz there's no telling how long that could take to resolve. In the meantime, I can't do any programming.
Using Fedora 14 with Gnome 2.3 Desktop utilizing Compiz and Emerald theme manager. When I empty the trash, the icon is still the FULL Trash icon. I tried using different Emerald Themes, and different Icon sets, but still the Trash Icon stays full. I checked the trash folder in $HOME/.local/share/trash and found nothing, no hidden files.
View 3 Replies View RelatedBash acts weird in 10.04 server. Whenever I try to run .sh scripts, every empty line in the script results in "command not found". Then on even simple scripts I get syntax errors, but the same exact scripts work on my 9.10 desktop installation. There's also another problem, I'm not really sure if it's bash-related. After setting the proxy using
[Code]...
I am trying to understand the join command. I wish to join two files:
Code:
$ cat test1
a 0
b 2.51
c 19.85
$ cat test2
a 0
b 2.51
[Code]...
this is great but I do not understand why join ignores the -e flag and fails to insert FOO in the empty field.
I'm in a directory containing various files and subdirectories, one of which is called BACKUP and is initially empty, what exactly happens if I launch the following command line:
Code: cp -R . BACKUP???
If I'm not mistaken, all the content of the current directory should be copied into the BACKUP directory, apart from the directory BACKUP itself. Actually I get a message saying something like:
Code: cannot copy a directory onto itself BUT when I look into the BACKUP directory I find another directory called BACKUP which I did not expect to find. Moreover, if I launch the same command again I get the same message (repeated two or more times) and then I find that inside the "second" BACKUP directory there is a third one, with the same name again. In other words, every time I launch the command I get a deeper tree of "BACKUP" directories, as if the command was messing everything up. I know that most probably I'm the one who's messing things up and I also know the "problem" can be easily bypassed by using as a destination for the copy a directory located elsewhere, but I'd like anyway to understand the reason for such a behaviour.
know the basic command for reading the README file after you tar the program using terminal Ubuntu 11.04.thx
View 2 Replies View Related