General :: Bash Script Variable NULL Instead Of Value Of Expression?

Nov 17, 2010

Quote:

#!/bin/sh
for i in {1..10}
do
for j in {1..50}

[code]....

The first echo generates something like: abc.de.fgh The second echo generates:

View 3 Replies


ADVERTISEMENT

General :: Bash - HISTSIZE - Readonly Variable -bash - HISTFILESIZE - Readonly Variable

Dec 8, 2009

On one of my servers I see this when I log in. What does this mean and how can I get it to go away? Everything seems to work fine, but none of my other machines give this error.

View 5 Replies View Related

Programming :: Null Pointer In Bash?

May 19, 2011

#!/bin/bash
sed -n 8p file.txt

returns the 8th line to the StdOut.

If I assign the value to the variable line = $(sed -n 8p file.txt)

and now print it out with echo

echo $line

the line would be printed.

But what if the file has only 4 lines. What value would be assigned to the variable line?

I want to know that because I want to only print it if the value is "something", that is not null.

In Java for example I would do it like this...
String line = "";
line = reader.readLine(); // or anything else..
if(line!=null){
System.out.println(line);
}

How would I check if the value is not "null"(I don't know if bash knows null)

View 13 Replies View Related

Programming :: Bash - Read Content Of File To Variable And Use This Variable In For Loop ?

Aug 21, 2009

I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.

For example:

Code:

Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).

View 6 Replies View Related

Software :: Get Variable From Text File Into Bash Variable?

Jun 10, 2009

I have a text file i that has a mailTo: NAME in it. In a bash script i need to extract NAME and put it in a $variable to use. How do i do this?

View 2 Replies View Related

Programming :: Bash - Expression Is Always Evaluating To True

Jun 7, 2011

This line if [[ $hamachi_reachable = true && $lan_reachable = true ]]; then is always evaluating to true. I gave two ips that are not valid, so that both variables would become false yet the whole expression is evaluating as true. With that set -x in there, I get this output.

Where am I going wrong?

Code:

View 11 Replies View Related

Server :: Kernel Panic - WARNING: Can't Access (null) Exec Of Init ((null)) Failed

Aug 5, 2010

I have a server running Red Hat Enterprise Linux ES (2.6.9.55.ELsmp). When it starts up I get the following error: Uncompressing Linux... Ok, booting the kernel. Red Hat nash version 4.2.1.10 starting WARNING: can't access (null) exec of init ((null)) failed!!!: 14 unmount /initrd/dev failed: 2 Kernel panic - not syncing: Attempted to kill init!

After that I got no response from the OS. I have the installation CD, so I tried to start the rescue mode, while going through the steps I received an error stating that mounting to /mnt/sysimage failed and that if I want to I can access a shell. I really don't know what to do from here

View 6 Replies View Related

General :: Get N-variable Parameters In Bash

Mar 21, 2011

I've a script that it's invoked with n-variable parameters. Here's an examples:

Code:
./myprogram.sh inputdir FIELD1 FIELD2 ... FIELDN outputfile In the script I would like to get the FIELD names that were passed.

View 4 Replies View Related

General :: Substitute Variable In Bash

Mar 21, 2011

Assume that i a having the following three lines in an executable file

#/bin/bash
a=Tue
Tue=1

When i give echo $a the value should be 1, how to do this.

View 8 Replies View Related

Programming :: Bash Script: Catch File Not Found Error And Send To /dev/null

Apr 21, 2010

I have the following working script. It checks the directory for txt files, if files are there, it copies to another directory or gives error. I would like to exclude "file not found" errors and send them to /dev/null. All other errors should go to the email address as usual.

Code:

#!/bin/bash
function err
{
if [[ $? -ne 0 ]]

[Code]....

View 7 Replies View Related

Programming :: Bash - Syntax For ((<arithmetic Expression>)) Usage ?

Mar 18, 2010

I do not understand bash' syntax regarding the use of ((<arithmetic expression>)). $((<arithmetic expression>)) is tokenised to a single word. OK.

Code:

In isolation

Code:

It may not be used where a word is expected. This generates a syntax error. Why?

Code:

View 6 Replies View Related

General :: Bash: Input Password Into A Variable?

Aug 22, 2010

I'm basically setting up two sshfs mounts and I have it set up so I run one command but type my password twice.Is there an easy to way to input a password using bash and pass that variable to another process asking for a password?

View 5 Replies View Related

General :: Bash Variable As Parameter To Script?

May 10, 2011

I want to create a variable that when passed as a parameter to another bash script will keep its string quotes (so it stays as one parameter). What ways can I achieve this cleanly?

Code:

john@ubuntu:/usr/local/src$ cat foo.sh
#!/bin/bash
echo $0

[code]....

View 8 Replies View Related

General :: Concatenate Variable Names In Bash?

Apr 7, 2011

In my script, and I would like to concatenate 2 variables names, to give me the true variable.I've 3 variables X1, X2 and X3, and I invoked them inside a for loop.

Code:
#!/bin/bash
X1=HELLO

[code]....

View 4 Replies View Related

General :: Reading File Into Variable In Bash?

Mar 21, 2011

I know that cat can output the file, but how do you store that output in a variable to process:

Code:

CONTENT=cat file.txt

This doesn't seem to work?

View 3 Replies View Related

General :: Bash Catching The Function Returning Value Into A Variable?

Mar 17, 2010

i am dealing with this problemI have a function

function Une {
...
return $some_variable

[code]...

View 6 Replies View Related

General :: Bash Script - Forget Global Variable's Value?

Apr 9, 2011

I have a hard time with my bash script.

It forget global variable's value.

First look at my script.

Code:

Echo "PKGS is [$PKGS] in after loop"

And data file for it is below. Let's name as list.txt

Code:

As you see, PKGS variable in loop has correct value.

However, after loop I can not get proper value for it.

View 5 Replies View Related

General :: Simple Bash Command Causing Bad Variable Name

Feb 18, 2010

When I run this command from shell, it runs ok
export REVS=`svn info svn+ssh://svn.myone.ca/var/svn/story/trunk/lib |grep 'Last Changed Rev:'| awk -F: '{print $2}'`
However when I save it into a file called test.sh (of course, I chmod it with +x), I got error "export: 2: bad variable name"

Here is the file:
#!/bin/bash
export REVS=`svn info svn+ssh://svn.myone.ca/var/svn/story/trunk/lib |grep 'Last Changed Rev:'| awk -F: '{print $2}'`
I am using ubuntu.

View 7 Replies View Related

General :: Environmental Variable In Bash Command String?

Feb 9, 2011

I do this:

Code:

a@b:~$ export A=hi
a@b:~$ echo $A
hi
a@b:~$ bash -c "export A=blah; echo $A"
hi
a@b:~$

Why doesn't the bash command print the new value of $A? Is there a way to make it do so?

View 6 Replies View Related

General :: Pull String From A File Into A Variable Using Bash

Aug 6, 2011

I have a file (.tmpfile) and inside it is a string which i only know part of, the rest being a random group of characters... I would like to know how to pull the whole string out of the file and into a variable.

View 13 Replies View Related

Programming :: Reading A Bash Variable In Bash Scripting ?

Nov 26, 2008

I have a config file that contains:

my.config:

Code:

Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.

Here is my parse_cmd script:

Code:

View 3 Replies View Related

General :: Bash: Substitute Parameter In A Quoted String - Stored In Another Variable

Jan 31, 2010

(variable substitution?)
(parameter expansion?)
Code:
run_repeatedly()
{
NUM=0
while [ <irrelevant stuff here> ]
[Code]....

run_repeatedly "programX -o "./messy/path/output-$NUM.txt"" The echo inside the loop prints "...-$NUM.txt"; obviously I'm aiming to have bash substitute the iteration number so that I end up with many output files not 1.

View 5 Replies View Related

General :: Bash Variable Naming The Server - Monitor Trunk Failure?

May 30, 2010

I'm writing a script for asterisk to monitor trunk failure, i do a loop for every trunk it got nad would like to name variable like server1=, server2= naming the server upgoing as the trunk is. here is the scripts:

[Code]....

what i would like to do is name the variable server, username and status with the count variable, like this server$COUNT to have server1 when on trunk one, bu as soon as i add the $COUNT after the server, it seems to try to make it a command, it says that:

Code:
./test.sh: line 45: server1=74.63.41.218: command not found

View 7 Replies View Related

General :: Bash Variable - Simple Script For Finding And Copying Files Powered By The Command?

Aug 2, 2009

Ive been using linux for a while but I am just getting into shell scripting, im currently trying to get a simple script for finding and copying files powered by the command:

Code:

This works fine from the command line but when put in a script such as:

Code:

Code:

with the keyboard inputs for $fc1 and $fc2 being *.doc and ~/test respectivly. The only problem i can see is the xargs -ivar "var" part possibly needing $var to be defined?

View 2 Replies View Related

Ubuntu :: Mapping HAL's .fdi Expression To Xorg Expression?

Oct 6, 2010

I want to translate this .fdi clause

Quote:

<match key="info.product" string="PS/2 Generic Mouse">
<merge key="input.x11_options.EmulateWheel" type="string">true</merge>
<merge key="input.x11_options.EmulateWheelButton" type="string">2</merge>[code].....

into its Xorg equivalent. What does it look like?

View 1 Replies View Related

General :: Assign An "here Documents" Section To A Variable In Bash?

Mar 11, 2011

Is it possible to assign an "here documents" section to a variable in bash?I would like to assign the following to a variable:

Code:
<html>
<body>
<p>THis is a test</p>
</body>
</html>

View 4 Replies View Related

General :: Bash Script: Use The Directory Of The Script File As Variable?

Jan 16, 2010

i'm not actually using Linux but i figured this might be the right place nonetheless..o i've got this little script file to compile and run some Java code:

Code:
#!/bin/bash
cd /Users/acid/Desktop/javaTest

[code]...

View 12 Replies View Related

Ubuntu :: Bash Variable And /bin?

Mar 28, 2010

I'm making a script I want to be able to just call (ie, rclick instead of ./rclick) where do I put it?

~/bin?
/bin?
/usr/bin?

Also, how do I pass a variable to the script (rclick 10 will rightclick 10 times) (Found, so simple... $1)Lastly, can I force it to run on CPU2? CPU1 is completley locked up if I run this on it... Or can I make it use less cpu cycles?

View 2 Replies View Related

Programming :: Sed A Variable In Bash?

Mar 25, 2011

I have beat this enough and don't get what should have been a very simple thing to do. I build a variable;

Code:
CLIST=java,lua,python,php,perl,ruby,tcl
CLIST will be used by another bash script but I need to replace the commas with a space. I

[code]...

View 2 Replies View Related

Programming :: Variable Substitution In BASH?

Feb 17, 2011

Just a simple BASH for loop to read the file path from a text file (clean.txt) echo the variable for debug purposes, and scp it to a server I have using port 50 for SSH.

I've already formatted the entries in clean.txt to handle spaces correctly, using sed replacement.

Example from the clean.txt file:

Code:
/MP3/NAS000000001/Barenaked Ladies/Barenaked Ladies - Barenaked For The Holidays/20 Auld Lang Syne.mp3
/MP3/NAS000000001/Barenaked Ladies/Barenaked Ladies - Barenaked For The Holidays/14 Deck the Stills.mp3

[Code]....

View 5 Replies View Related







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