Ubuntu :: BASH Quote - Calling Commands Stored In A Variable?

Feb 19, 2010

I am having some weird problems with calling commands stored in a variable (I need to do this to assemble a command with a bunch of parameters automatically and then execute it).Example code that will replicate the weirdness:

$ echo "hello world" > "test file.txt"
$ cat "test file.txt"
hello world

[code]....

I would expect the output to be:

hello world

What happens to the quotes? I have tried various combinations of single quotes, escaped quotes, etc, but it seems like quotes in a variable are not evaluated as quotes when that variable is executed.

View 9 Replies


ADVERTISEMENT

Programming :: Where Are BASH Commands Stored

Feb 21, 2011

Where are the other BASH commands/exe stored? If the commands are part of the exe of BASH than ls would not be in a path, correct?

View 11 Replies View Related

Programming :: Bash - Calling A Specific Variable Based On User Input?

May 3, 2011

I'm trying to call a specific variable based on a user selection. For example:

Code: Select a file:

[1] foo.tar
[2] bar.tar

Enter a selection: I have already coded each possible selection to have its own variable. If the user selects 2 I need to select $SELECTED_TAR2, or if they select 1 I need to select $SELECTED_TAR1 and then do something like this behind the scenes:

Code: cp /home/user/$SELECTED_TAR2 /home/user/backup/$SELECTED_TAR2

I was thinking something like this:

Code: echo "Enter a selection: "
read -e SELECTED_NUMBER
cp /home/user/$SELECTED_TAR$SELECTED_NUMBER /home/user/backup

[code]....

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

Programming :: Calling Bash Script With More Than One Variable From Python Script?

Oct 4, 2010

I am calling a bash shell script from a python script trying to pass several arguments to the bash script with no succes can this be done? I have researched (google) with no clear indication of how to achieve this. Using "os.system"

View 4 Replies View Related

General :: Bash - Get ' Quote ` Back-tic Through The Shell Into Sed?

Aug 3, 2011

In linux how do I to get the ascii decimal/hex/oct code from a char or a ascii char from a decimal/hex/oct code. I see from the gnu sed user manual that I can use the d# o# x# to specify a character but I am not sure how to use that. If some one has a better way to get the the ` and ' chars through I want to sed with the backtick '`' character and ''' single quote character.

sed '/`/p'

these don't work

sed '/'/p'
sed '/`/p'

View 3 Replies View Related

Ubuntu :: Bash Command That Automatically Inserted A Quote At The End Of Email?

Feb 16, 2010

What's that bash command that automatically inserted a quote at the end of your email? Can't recall exactly, is floating round at the back of my mind.

View 4 Replies View Related

Programming :: Escaping A Single Quote From A Bash Script?

Jul 21, 2010

There is probably a very simple fix, but its wrecking my buzzI call the following on the command lineR CMD BATCH '--args Y_filename="one.txt" out="two.txt"' brew.RI want to call this from a bash script but replace one.txt with $1, and two.txt with $2 (ie the first two arguments from the command line)I have tried in vane"R CMD BATCH '--args Y_filename="$1" out="$2"' brew.R"

View 8 Replies View Related

General :: Calling A Script And Giving It A Variable?

Apr 22, 2011

I have a script1.sh (see code below) which calls another script (which is a sort of template -> template.sh). But when i call template.sh i need to send an argument with it.

Code:

#!/bin/sh
VAR=`./template.sh -d $dirpath`
exitstatus=`echo $VAR`

[code]....

echo "$VAR files which are older than 1 hour in folder $dirpath" exit $exitstatus I geuss the command should look like something like this command

Code:

./script1.sh -d /

You don't have to look at the code of template.sh, thats not important. I just need to know how i get this to work I don't think it's that hard, but i just can't see it ...

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

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

General :: Does The Output Of The Previous Command Get Stored In Any Variable

Mar 26, 2011

For example, when using bash you can use

Code:

to execute the previous command or

Code:

!<number> to execute the Nth command(use history to see the list). Or you can use

Code:

cd !-2:1

to cd into the value in the first field that was executed 2 commands ago Anyhow, say I run a command and the output is a path. Any way to cd and then some variable where OUTPUT of the previous command was stored? A variable that always stores the OUTPUT of the last command.

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

Ubuntu :: Calling Firefox Macros From Bash?

Nov 27, 2010

I would like to call some firefox macros from bash so that I can manipulate them in some scripts. Does anyone know how to do that?Currently I'm using the imacros firefox add-in

View 1 Replies View Related

Programming :: Calling Bash Script In Php?

Jul 17, 2010

I have a bash script that changes the iptables.Now i call this bash script in my php code.When this bash script is running the part of code that contains iptables instruction is not running because we need to be in superuser mode(root)

View 14 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 :: Running Bash But Common Bash Commands Not Working?

Jul 17, 2010

below are the details of my system. I have bash as my current shell, some really common commands aren't working.

Do I need to do a re-installation of bash? Or how do I install a selection of bash commands which I need? (for example a subset of [URL])

Code:
root@sdptfw:~ # uname -a
Linux sdptfw.sdpt.co.za 2.4.36 #1 Tue Jul 22 13:13:24 GMT 2008 i686 i686 i386 GNU/Linux
root@sdptfw:~ # echo $SHELL$
/bin/bash$

[Code]....

View 13 Replies View Related

Ubuntu :: Where Are Bash Profiles And Gnome Panels Stored

Jan 5, 2010

I have a bash profile (with custom terminal color settings) and also a gnome panel (with quick-launchers on it and other customizations). Assuming these things are stored in text files, where in my ~home directory can I find them? I ask because I want to duplicate them on a another linux box to have the same bash profile/taskbar, and If I can do it by copying files instead of manually recreating them, it would be better.

View 2 Replies View Related

Software :: Bash Script Calling Make Files With CFLAGS Prepended?

Feb 6, 2010

Most all of this works when I execute it manually, but I cannot figure out how to get a bash script to execute it automatically.In this particular case, I am trying to build the xorg utilities. If I manually step through the process, prepending the commands with CFLAGS, LDFLAGS, etc, all of the packages build.So I created a bash script, test.sh:

Code:
#!/bin/bash
export INITFS=/initfs

[code]...

View 5 Replies View Related

Programming :: Calling Command From History Using Variable Like !$command?

Nov 19, 2008

suppose i store the history number of a command say :

1004 cat file

Then now i want to run it like : !1004 but by using a variable.

command=1004
!$command

i am getting errors like :

command=1004command

View 2 Replies View Related

Programming :: Access/Print A C Variable "as It Is Stored In The Memory"?

Oct 23, 2010

I would like to access/print a C Variable of any type "as it is stored in the memory". I would expect the output to be an array of bits. Whats the simplest/shortest way to do that?

View 14 Replies View Related

Programming :: Python : Pass Output Of System Commands To Variable?

Jan 25, 2011

I'm trying to write a python script that will use the current user's name when interacting. Ex: when started, it should say "hello daweefolk" when I am logged in.
I've tried
Code:
username=os.system("echo $USER")
but the variable remains empty.
What is the correct code?

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

General :: SSH Connection From BASH Script Stops Further BASH Script Commands

Dec 3, 2010

What happens when the script executes is that the ssh connection works and parks me at the remote hosts's shell login. Therefore, the "firefox" command refuses to execute. I need to know how to make the "ssh" connection occur, stay open, and go into the background so that the rest of the script can execute.If I could also do this with the "firefox" line so that the entire term window could be closed would also be helpful.

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

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

Software :: Calling A Bash Shell Script From Within Another Script?

Apr 9, 2010

I am trying to call a script say mkdir.sh into another script that will make use of the dir's which are created in the first script. I know that I could code it all together, but I am trying to avoid rewriting the mkdir script as it is long.

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

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

Fedora :: Where Are Stored PWs For Remote Desktop Viewer Stored?

Oct 20, 2010

I have machine that I used to VNC to on my network with Remote Desktop Viewer from my Fedora 12. When I first connected I checked the checkbox that I wanted to store the pw. Now the pw on the other machine has changed but Remote Desktop Viewer does not ask for a new password, it just gives me a black screen, like I am connected but I can't see anything. I'd like to know if anyone knows where this pw data is stored on the system so I can start fresh. I already tried uninstalling Remote Desktop Viewer and installing it again.

View 1 Replies View Related







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