Programming :: Bash If *sometimes* Fails To Detect Embedded Newline

May 21, 2011

Using xsel I pass a selection into a variable. I then check that the variable includes an embedded newline to be sure that the selection returned by xsel is complete. If the selection content preceding the newline is just a single word, the check fails to detect the newline, thus

Code:

g fnm=`xsel`
g cat <<< "$fnm"
Whatis
apropos sear

[code]....

View 14 Replies


ADVERTISEMENT

General :: Echo Newline Character Not Working In Bash?

Mar 11, 2011

I have bash script which has lots of echo statements and also I aliased echo to echo -e both in .bash_profile and .bashrc, so that new lines are printed properly for a statement like echo 'Hello World' the output should be I even tried using shopt -s expand_aliases in the script, I am running my script as bash /scripts/scriptnm.sh; if I run it as . /scripts/scriptnm.sh I am getting the desired output.

View 4 Replies View Related

Programming :: After USB Boot - Detect Which Device The Ramfs Was Loaded From - Bash Or Python

Sep 22, 2010

How one could determine (for use in a Bash or Python script) which device (eg /dev/sda1, /dev/hda1... etc) a ramfs was loaded from when booting from a USB drive.

I have a RIPLinux/Tinycore live USB disk that automatically needs to run a script that is stored on the same USB drive but not part of the RIPLinux/Tinycore image. (Please note that I do not want to put this script into the RIPLinux image.) I therefore would like to remix the RIPLinux/Tinycore ISO to automatically run this script once it has started up. After RIP linux has booted I would like to automatically mount the USB drive that RIPLinux/Tinycore was booted from. I need help detecting which device this is.

View 3 Replies View Related

Programming :: Kill Follow-on Code If Source Fails In Bash?

Dec 20, 2009

I have a Bash script that runs other bash scripts. If the parent code fails, is there any way for me to also kill the child code?That kills any multiple instances of a script if I run it more than once. Is there any way I can just modify this into something that prevents the child code from running/continuing from running if the parent stops from an error?

View 3 Replies View Related

Software :: Dpkg - Add / Remove Package Won't Work - Terminal Goes: Bash Syntax Error Near Unexpected Token `newline'

Mar 11, 2010

When I am adding removing packages to get more hard drive space, this is not the first time I left too many pages open and it crashes on me. My son would fix it by typing in the terminal sudo something, but I want to know how to do this. The only thing not working is the add/remove packages at the moment. Here is what it said, E:dpkg was interrupted you must manually run 'dpkg--configure -a' to correct the problem E: _cache-open()failed please report. Please, could someone tell me how to get the default back or whatever. When I type in the terminal, it refused my password until I tried several times, plus, it finally says in the terminal No such command. Bash. No such command. I am hoping this question is one you do recognize the answer for.

I tried using Yum to remove the package. Like this:

To remove or uninstall a package:

Code:

yum -y remove ,package name>

Terminal goes: Bash syntax error near unexpected token `newline'

View 3 Replies View Related

Networking :: Apt-get Fails From Embedded Board

Dec 1, 2010

I am running Virtual Box Ubuntu Linux 2.6. Connected to my PC is an embedded board running debian 2.6.32. I have ip forwarding on at my virtual box. From my embedded board I can successfully ping www.google.com. I want to download and install some packages but when I try apt-get I get the following: I've flailed away at this for most of the day

[Code]...

View 3 Replies View Related

Programming :: Perl About System Command / Fails If The Standard Shell Is Dash And Not Bash?

Jun 30, 2011

I am trying to fix a perl script, and I really suck at perl. But I think this problem will be easy for people who know it.

The problem is, I have an old setup script someone wrote many years ago. It fails if the standard shell is dash and not bash. The only way I've gotten it to work is to point /bin/sh to bash. I looked thru the script and it uses "system" many places, and I think that's the problem.

I searched for it and found this link:url

My plan is to include this function:

Code:
sub system_bash {
my @args = ( "bash", "-c", shift );
system(@args);
}
Then I could simply change all calls to system into system_bash and it should work?

The parameter to the system calls is usually some variable. What if the parameter is a list already? Do I need to test for it somehow, and if it's a list, prepend "bash" and "-c" to the list? How do I do that?

In the script there are lots of places like this:

my $error = system($cmd);
if ($error) {
die/warn "some error message";
}

Shouldn't there be a return in the system_bash function?

View 8 Replies View Related

Programming :: Prevent Sed From Replacing With Newline

Nov 28, 2009

I'm writing a script to replace some text that exists in about 50 .lex, .y, and .cc source code files, sometimes more than once in a file. Sometimes the text is in a multiline C comment, and other times it's within a multiline C string.

I use sed to grab the start and end of each line and wrap the new text in the old whitespace and/or quotes and Problem is, sed is changing the characters into a newline.

Is there a way to tell sed to not process escape sequences? I tried using several variations of

Code:

To no avail. Or could it be bash?

I would give up on the script and do it by hand, but this is something that I must do from time to time.

Here's the function which replaces the first occurrence found:

Code:

When $post is printed by echo, it shows the - but by the time the file is on disk, it becomes a newline. What should I do to ensure that it stays as the characters ?

View 4 Replies View Related

Programming :: Sed Command To Replace 7th Tab With Newline

Mar 11, 2011

I have a tab delimited file. I need to replace the 7th tab with a new line.

I tried the following command (but it does not work):

The above simply spits out the original file.

If I write the next command, it replaces the first tab in each line with a newline. How can I make it replace the 7th tab in each line?

View 4 Replies View Related

Programming :: Using An Alias Or Function Without The Newline?

May 1, 2010

I want to create an alias or function that when used prints something like this on the command line so I can further modify it before pressing enter myself.

Code:
$ FILE=exercise1; cc -o $FILE $FILE.c && ./$FILE; FILE=
The idea is that I'm studying c and want to change the name of the file once instead of

[code]....

View 3 Replies View Related

Ubuntu :: Embedded Commands In Bash?

Apr 7, 2010

I would like to be able to connect to a machine, list a directory, wait long enough for me to see the results then move on to the next machine.This is failing:

Code:
#!/bin/bash
while read line; do

[code]...

View 3 Replies View Related

Programming :: Invoke Java From Bash Terminal Via Shell Script Fails Under Mint Debian / Fix It?

Feb 16, 2011

I am running a Java application on the command line bash terminal under Mint Debian. I have JDK1.6.0_22 installed 64-bit, and the OS is 64-bit too. I have a few JAR files in the directory and a few native LWJGL libraries. When I run the application using the command line, all works fine.
Lets assume my directory where the files are is called /home/riz/MyGame. I change to that directory and this is the command I use code...

View 3 Replies View Related

Software :: Replace Newline Pattern In File By Other Newline Pattern In A Shell Script?

Nov 22, 2010

I have several (vhdl) files containing a pattern with newline characters that I need to replace by another pattern that also contains newline characters.

I start with something like:

Code:

I want to replace it by something like:

Code:

(I need to paste some lines)

As I need to do this (very) often I want to use a shell script.

I tried:

1.

Code:

result:

Code:

2.

Code:

result:

File remains unchanged

3.

Code:

result:

Code:

4.

Code:

result:

Displays the unchanged testfile

How I can automate the pattern replacement?

Code:

View 9 Replies View Related

Programming :: Inserting Multiple Lines - With Newline - Using Sed Or Awk

Mar 8, 2009

I need to replace part of a line in a file with multiple lines, however need to separate each line with a newline is this possible?

Example, need to remove line 2

And insert line similar to below:

If the multiple lines were part of a text file, would inserting a text file automatically include newline characters?

View 1 Replies View Related

Fedora X86/64bit :: Yum Update Fails Due To Missing Php-embedded Package?

Nov 20, 2009

my update today failed, because the packages raydium and maniadrive depend on libphp5-5.2.9.so, which is provided by php-embedded, which is (apparently) not in the fedora 64bit repository There does however seem to be an i586 version...

View 2 Replies View Related

Programming :: Adding Form Feed After Newline For Windows?

Apr 27, 2010

I can't get x to work with a mouse so I have to use a windows computer to do that from for now. The problem is I remember there being something about windows using a newline AND carriage return and linux just using a newline. I was about to cut and paste code but the lines go on and on instead of breaking off where they did in linux. I was going to write a perl script but don't know how to add a carriage return to the end of each line.

View 3 Replies View Related

Ubuntu :: Create New Directory But Keep Getting Same Error - Bash: Syntax Error Near Unexpected Token `newline'

Jan 13, 2010

I'm trying to create a new directory using the mkdir command.

Code:

home@ubuntu:~$ mkdir <aicoursework>
bash: syntax error near unexpected token `newline'

that's the error that i keep getting, what am i doing wrong?

View 5 Replies View Related

Programming :: Pty Programming-Extra Newline ?

Nov 11, 2009

I'm having a hard time figuring out why the program posted below prints an extra newline every time I type the enter key.This program is using the master pseudo-terminal to send the password and receive the output from the slave(connected to the passwd program).I suspect this has to do with the terminal line discipline(s)(2 considering the master and slave), but I can't really understand why.I have tried turning on/off several terminal special characters but to no avail.

Source code follows(compiled in x86, Slackware-13.0 - linux-2.6.31.5 - gcc 4.3.3):

Code:

View 14 Replies View Related

Programming :: Write Regexp That Matches String That Begins With Whitespace Or Contains Newline?

Dec 10, 2010

How do I write a regexp that matches a string that begins with whitespace or contains a newline, but not necessarily both?

View 2 Replies View Related

Programming :: Keep The Bash-script Running If "exec Command" Fails

Aug 13, 2010

Is there a way to use exec, but if exec fails to go on with the script?

Example:

Code:
#!/usr/bin/env bash
exec startx
echo "Starting of X failed"

If startx fails, the echo will be seen on the screen. I tried all kind of stuff, but guess it ain't of much use to post it here. I searched the web, but searching for "exec and bash" in one sentence does give results which are not what i am looking for.

View 6 Replies View Related

Programming :: Mysql Embedded In C (/usr/bin/ld: Cannot Find -lmysqld)?

May 10, 2010

I found a program from :

Quote: url

with this source :

Quote:

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "mysql.h"
MYSQL *mysql;
MYSQL_RES *results;
code....

what is the problem?

View 6 Replies View Related

Programming :: Find Sound Device - To Work On An Embedded Board ?

Feb 1, 2010

I'm trying to get sound to work on an embedded board. The boot says ALSA is present and sound chip is present. So I try to open the device with:

The hardware manufacturer assures me the device is hw:0,0 so I set device to:

This gives me:

So I'm presuming the advice that I use hw:0,0 must be wrong? So I need to find a way of working out what the device id is. I've tried default, no effect, then tried the command asoundconf list, which returns an error. I'm using a min linux build on an embedded system (busybox) so is there a way to find my sound device.

View 2 Replies View Related

General :: Bash - Detect When A Terminal Gets Focus?

Jun 23, 2011

I want to be able to time how long I spend in front of a terminal. I'm thinking the best way will be to have some sort of timer that starts and stops when the terminal gains/loses focus. And it will have to work with multiple terminals...

I'm using GNOME.

View 3 Replies View Related

Ubuntu :: 10.10 - Cannot Detect Subdirectory (Bash CD Error)

Dec 21, 2010

I'm trying to change to a subdirectory:
Code:
tony@advent:~/scratch$ cd Home-Arch
bash: cd: Home-Arch: No such file or directory

So I list the contents of the current directory:
Code:
tony@advent:~/scratch$ ls
duhome Home-Arch qcad_1.dxf qcad_1.svg runme stdout

OK, I assume I have mis-typed the subdirectory name in ways I cannot detect, so I copy the sub-directory name from the output of the 'ls' command, while within the terminal window, and paste it into the next 'cd' command:

Code:
tony@advent:~/scratch$ cd Home-Arch
bash: cd: Home-Arch: No such file or directory

I browse the directory and sub-directory in Nautlius - everything is there where I expect it to be. The folders/files are not hidden. What is happening here?

View 8 Replies View Related

Debian Installation :: Attempt To Install From USB Fails To Detect Cdrom

Jan 31, 2016

I am attempting to install debian for the first time on my pc that has no cdrom drive. I downloaded the Jessie CD image and wrote it to a 4GB stick, it didnt work. Then tried the netinstall image but face the same issue.

To write the usb stick I used unetbooting first, then tried win32diskimager and finally tried DD while stick was not mounted

Code: Select alldd if=debian.iso of=/dev/sdb BS=4MB; sync

Issue is still the same: I boot from the usb and after selecting language and keyboard it fails to detect cdrom drive (no drive at all in my pc). Same behavior using normal or expert mode.

Im also unable to manually specify the drive (it looks at /cdrom and I wanted to change it to the usb stick itself or mount usb to /cdrom but I cant find my stick in /dev)

View 14 Replies View Related

Ubuntu Networking :: Unable To Detect Router - Tries To Connect But Fails?

Apr 24, 2010

Ubuntu 9.10 comes with rt2870, the driver for my Zonet ZEW2545, and I have had to blacklist rt2800usb in /etc/modprobe.d/blacklist.conf in order for rt2870 to work. My network adapter is able to attempt to connect to my router, but after 10-40 seconds it tells me I am disconnected again. This adapter works fine on windows.

View 1 Replies View Related

Programming :: Saving File Data Using Python In An Embedded System In An Safe And Fast Way?

Apr 19, 2011

I am developing a program in a system where the Linux does not take care of the sync command automatically. So I have to run it from my application always I save some data in the disk, which in my case is a 2GB sdcard. It is true that I can make the operation system takes care of the syncronization, using a proper mount option, but in this case the programm's performance drops drastically. In particular I use the shelve module from Python to save data that comes from a socket/TCP connection and I have to deal with the potencial risk of the system being turned off suddenly Initially I wrote something like that to save data using shelve:

Code:

def saveData(vo)
fd = shelve.open( 'fileName' , 'c')
fd[ key ] = vo
fd.close()
os.system("sync")

But that takes too much time to save the data. Note that I use the sync from the OS every time I close a file to prevent data corruption in the case of the "computer" being turned off with data even in the buffer. To improve the performance I made something like that:

Code:

def saveListData( list )
fd = shelve.open('file_name', 'c')
for itemVo in list:
fd[itemVo.key] = itemVo
fd.close()
os.system("sync")

Thus, first I saved an amount of objects in a list then I open the file and save the objects. In this way I have to open the file just one time to save a lot of objects.However I would like to know if adding a lot of objects before closing the file would increase the risk of data corruption.I known that turning off the system after fd.close() and before os.sync may cause problems. But what about turning off the system after

Code:

fd = shelve.open('file_name', 'c')

but before fd.close()?

View 7 Replies View Related

Ubuntu :: How To Detect When EthX Interface Is Down From A Bash Script

Jun 11, 2011

I'm trying to write a small script and there's one part of it that makes me sick:

Code:

ifconfig eth$num down
sleep 6
ifconfig eth$num hw ether $mac
ifconfig eth$num up

The problem is that the ethX interface doesn't go down immediately after the first line is executed. So sometimes the change of MAC is called while ethX is up, no matter how big is the sleep time, which results in an error. Is there a way to make this work right?

View 1 Replies View Related

Hardware :: Adaptec 39160 Scsi Fails To Detect Seagate Drive

Dec 4, 2010

just bought an adaptec 39160 PCI scsi controller and 34Gb drive and installed it on my computer.When i Booted it up a utility thing ran which said 'detecting array' and it found the drive and its size etc. it didn't go any further to allow my system to boot, so I rebooted and pressed CTRL + A to enter the adaptec scsi config. I changed something in there to make the disk non bootable (i Think) and rebooted the system.

It now hangs at :

'Detecting Array .....'

and does not show the drive details or the CTRL + A option to enter the utilities. So the only option I have had is to remove the adaptec controller ( and the system boots fine) the mother board is an Abit an8 ultra - probably about 4 years old and cpu is amd 64 I guess i have broken it and my remedy would be to reset the default options on the adaptec controller, but you can probably guess I have v. limited knowledge and have not used scsi before.

View 1 Replies View Related

Debian Installation :: 'Squeeze' AMD64 Installer Fails To Detect Hard Disk

Apr 20, 2011

Having trouble installing 'Squeeze' 6.0.1a-amd64-netinst on a new AMD64 system.The installer boots and runs fine until it gets to hard disk detection. Then it hangs for about 20 minutes showing a blue screen, during which time the HDD-activity light flickers every 5 seconds. Eventually it says it can't detect a hard disk, and displays a (longish) list of possible drivers; no idea which, if any, would suit.Anyone else installed (successfully or otherwise) on this combo?

View 3 Replies View Related







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