Slackware :: Bash: HISTTIMEFORMAT: Read Only Variable

Nov 11, 2010

I have a problem when i ried run this command (export HISTTIMEFORMAT="%F %T ") on slackware 13.0. the answer is the following (-bash: HISTTIMEFORMAT: readonly variable) I am running this command on the bash like root.

View 2 Replies


ADVERTISEMENT

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

Ubuntu :: Read A Variable From File (bash Script)?

Nov 8, 2010

I googled and tried to find an easy step by step-by-step guide on how to use a bash script read a variable from a file. This is the way I did it (but it does not really work so something is wrong, but what?) (testfil2 contains one line that readsidnumber=1578

#!/bin/bash
value="/home/user1/Desktop/testfil2"
echo $value
kill $pidnumber

View 4 Replies View Related

Programming :: Bash Scripting...read A Value From A File Then Assign To Variable?

Feb 27, 2011

At my wit's end I can't find anything that I understand well enough to use. This is for a Unix class, we are working with shell scripting. File1 has 5 in it and File2 has 100 in it.The teacher wants us to read the values then do the math. This is what I have so far:#!/bin/bashvar1='cat File1'var2='cat File2'var3=`echo "scale=4; $var1 / $var2" | bc`echo The final result is: $var3

View 9 Replies View Related

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

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 :: 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

Programming :: Bash Ctrl+c Tarp And Bash Read With Timeout?

Jan 24, 2010

simple bash code:

Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do

[Code]...

How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!

View 10 Replies View Related

General :: Getting HISTTIMEFORMAT To Work After Logout?

Oct 13, 2009

I've been trying to get timestamps on the history command. I found the following
export HISTTIMEFORMAT="%F %T " - and it works ok - but after I logout and log back in the history command is back to normal. So I did a little more searching and found this export HISTTIMEFORMAT='%F %T - %H:%M:%S ' >> ~/.bashrc I thought exporting to .bashrc would "save" the command - but I guess I am wrong. what do I need to do to get timestamps on history evertime I log on? how/where do I set it for all users?

View 9 Replies View Related

Programming :: Read A Foldername Into A Variable?

Jul 14, 2010

I am trying to write a script which can read the names of all folders within a given folder into separate variables. In effect, if a folder contains a folder "Folder1", "Folder2", "Folder3", the script would read those names into variables such as:

Variable1 = "Folder1"
Variable2 = "Folder2"
Variable3 = "Folder3"

I have tried fiddling with the find . command, but without any success.

View 3 Replies View Related

Ubuntu :: How To Make Variable And Read From Second Terminal

Apr 27, 2011

I have two terminals open and I want to save the current path in a variable and read it from the second terminal that I have open.

Then in the first terminal I type:
Code:
A=$(pwd)
And in the second I type:
Code:
echo $A
that doesn't work though.

I have tried also with
Code:
export A=$(pwd)
and
Code:
alias A=$(pwd)
but nothing seems to work. Is there a way to do this?

View 4 Replies View Related

Programming :: Read A Config Variable Into A Script?

Jun 8, 2010

What's the best way to read a value from a configuration file into a script?I'm trying to get the command_file vaule from nagios.cfg into a script, this works but what's the best way to do it?

Code:

command_file=$(perl -F= -lane 'print $F[1] if /^[[:space:]]*command_file[[:space:]]*=/' /etc/nagios/nagios.cfg)

View 5 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 :: Looping Using While Read Line And A Variable Instead Of A File?

Sep 24, 2010

I created the following.

x="top
middle
bottom"

I would like to make the following work.

while read line
do
echo $line
done

instead of importing a file I would like to use the variable $x I tried using pipes, but with no luck. My goal is to read one line at a time, but not have to export my data to another file, I would like to keep it all within one script.

View 3 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

Programming :: How To Use Bash Variable In C Code?

Feb 16, 2011

I want to write a c program with some shell scripts.Now For a simple C program. I am Setting a variable called val2 in bash, now I want to use bash variable val2 in C code. How do I do that?The above doesn't work (coz its spawning a different memory space and when shell script ends the variable dies with it as per my research but how do I keep them in same memory space)Also Is there any Good reference where they teach how to integrate C and Bash Together?

View 5 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) Keep Variable In Scope?

Jul 15, 2011

i've just started to learn about functions in Bash scripting. I'm able to set the functions and execute the commands correctly. However, if my_var is set in the first function and then later in the script in the script the 2nd function is called, it doesn't seem to remember my_var and quits (at least i suspect this is the problem).

Here's my code (it requires yad available via webupd8. org). My specific problem seems to lay in line #27 where if we view the changelog and then exit that window, it returns to the "main" function but any subsequent commands cause a crash. Is this because of the get command on line #29? It's presumably now out of scope after calling menu on line #25?

View 8 Replies View Related

Programming :: Bash - Passing Variable To Ssh?

May 8, 2010

I have a file with around 1000 IP addresses in it and I need to be able to ssh into each one of them, run a single command, and then exit. I already know the ssh command I want to run and it looks like this:

Code:

shpass -p [password] ssh -p 10022 -o StrictHostKeyChecking=no root@[ip variable] 'reboot'

(I know shpass is not good to use and keys are the correct way but I don't have any other options in this scenario.) if these ip addresses were in a .csv file, by themselves with no other information, how would I create a script to do the above command to each ip until the end of the file?

View 8 Replies View Related

Programming :: Passing A Variable To Bc In Bash ?

Jan 14, 2009

I cannot for the life of me get this little (simple) script I wrote to work. Here is the entire script:

Code:

#!/bin/bash
ASPECT=`mediainfo $1 |grep "Display aspect ratio" |cut -d : -f 2`
HEIGHT=`echo "320 / $ASPECT" |bc`
SIZE=`echo 320x$HEIGHT`

[code]......

An input filename ($1) is fed into mediainfo, which by the use of grep and cut spits out a single number which is the aspect ratio. This is then divided by bc into 320, which gives the desired height dimension for the file that I want ffmpeg to create for me. Finally, ffmpeg runs using the calculated dimensions... Basically, it's the passing of the $ASPECT variable to bc that seems to fail. It looks like bc won't read the output from the mediainfo line... It always crashes out with:

Code:

(standard_in) 1: illegal character: ^M I've tried doing something even simpler like this to debug by just trying it to display the calculation on the screen:

Code:

#!/bin/bash
ASPECT=`mediainfo $1 |grep "Display aspect ratio" |cut -d : -f 2`
HEIGHT=`echo "320 / $ASPECT" |bc`
echo $HEIGHT

and it does the same, so it's definitely bc that won't accept the output from mediainfo.

View 4 Replies View Related

Programming :: Setting Variable In Bash With Sed?

Jun 18, 2011

I am killing myself with this, please someone come to the rescue...

Code:
#!/bin/sh
IFILE=$@

[code]...

View 7 Replies View Related

Debian :: Sed With Bash Variable In Rules File

Jun 6, 2015

How can we do a file replacing string on debian/rules file using sed and bash variable ? I don't seem to be able to do so. I have tried below under the install section with arch dependent amd64, as far as I know all the bash commands are allowed to be executed in debian/rules file.

I have tried this :

Code: Select all
debian/rules file
ipaddr=`<long command to find ipaddr>`
myVar=`hostname`
sed -i -e 's/somestring/'$myVar'/g' $(configs)*
sed -i -e "s/somestring/$myVar/g" $(configs)*

[Code]...

Nothing works. Sed works but the hostname replacement doesn't work.

View 13 Replies View Related

Ubuntu :: Bash Script - Combine The Variable

Jul 23, 2011

Code:
#!/bin/bash
f1=apple
f2=banana
f3=grape
echo "Enter number 1,2 or 3:" # 3 is entered
read x
choice=${f+$x} # yielding choice=$f3
echo "$choice" # so $choice is, essentially, read as f3, which = grape

grape I am, essentially, trying to combine "f" and the number entered (3, for example) to create "f3", which when echoed as "$choice" will lead to grape!

View 8 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

Server :: Get Variable From Bash From Mysql Or Pass From Php?

Apr 26, 2010

I am not parsing on a webserver so is it possible to have both

#! /usr/bin/php &
#!/bin/bash

in the same script? Alternatively, I have a current bash script that I need to get some variables from mysql and not sure how to get mysql results in bash:

Quote:

mysql -h server.net -u username1 -paaa -e "USE squid; SELECT email, usern FROM TABLE WHERE blah blah;"
emailadd="resultfrom above"
usern="resultfromabove"

View 11 Replies View Related







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