Ubuntu :: Python - Export Variables To Bash Commands?

Feb 19, 2010

I created variables in python and would like to be able to incorporate those into bash commands that will be mixed into the script. Example:

Code:
name=raw_input("Type your name and press ENTER: ")
import os
os.system( echo "name")

Of course this doesn't actually work, but i think you get an indication of what I am trying to do.

View 1 Replies


ADVERTISEMENT

Ubuntu :: Bash Script With Variables And Editing Variables

Apr 6, 2011

mkvmerge -o <filename without extension>_TV.mkv -S <filename> && mkvextract tracks <filename> 3:<filename without extension>.*** && perl /home/brian/Desktop/ass2srt.pl <filename without extension>.*** && rm <filename without extension>.***

Doing these commands for multiple command line file inputs is the goal. So I can just type ./script.sh *.mkv in my terminal.This is what I have so far, but it doesn't work whatsoever.

View 2 Replies View Related

Ubuntu :: How To Export Per-user Process Variables

Mar 15, 2010

I can't seem to find how to export a variable to all processes I run under my user? I have an application that needs this variable, and currently I have to manually export this variable (typing "export VAR=... in terminal) every time before I run the application.

Which profile file I have to put the export expression into? I want all processes to inherit this variable, not just the shell/terminal. I.e. a true environment variable...

View 7 Replies View Related

Programming :: Allowing Export To Take Numbers As Variables?

Jan 26, 2011

I'm playing around with some shell scripting and I've got a directory call CS005 and I'm trying to write a script to I can locate to the directory really quick and easy.

export CS005DIR=/home/stud/0/043234/CS005

Now I get this error

CS005DIR=/home/stud/0/043234/CS005 No such file or directory.

This is because I've got numerical values within my variable.

Is there a way to allow numbers for variable names?

View 3 Replies View Related

General :: To Export Environment Variables In A File?

Oct 27, 2010

I want to export the env variables in a file using a script,i tried using the below:for var in 'env'

do
var2=env|awk -F '=' '{print$1}'
echo "$var;export $var2">file.txt

[code]...

View 9 Replies View Related

Ubuntu :: Export The Last 10-15 Commands?

Mar 3, 2011

How do I export the last 10-15 commands that I typed into the command line?

I want to keep a record of what I have done in my lab book.

View 2 Replies View Related

Debian :: Python 2.7 Can't See OS Environment Variables

Aug 23, 2015

I'm trying to compile Ardour on jessie amd64 using the Debian source code (there's already an ardour package but I want to use different compile options). I've applied the Debian patches and have all the required dependencies installed.

Scons quits with a KeyError message from python2.7 saying that os.environ['DEB_HOST_ARCH_OS'] is not defined.

Checking with 'dpkg-archtecture -l' shows that DEB_HOST_ARCH_OS=linux, but 'print os.environ["DEB_HOST_ARCH_OS"]' in python says that name 'os' is not defined. The scons script has 'import os' at the top so it should be seeing it.

How do I make this visible to python (I'm assuming this problem is specific to the jessie python2.7 installation and not python in general)?

View 1 Replies View Related

Programming :: Python: Create Variables From Dictionary Keys?

Jan 31, 2011

I have a situation where i need to turn a dictionary entry into a variable. I think i'm close, but am getting a syntax error (quoted at bottom)...

Code:
## Parameters.py
def dictionary_function():
p = {}
p['param_1'] = 10

[Code].....

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

Software :: Bash Shell - Export A Variable From A Script?

Jun 24, 2010

I need to be able to set a variable that is used by my build environment. I need to be able to change this variable "on the fly" as I work with multiple build environments. A portion of the variable is arbitrary, so I need to treat the arbitrary portion of the variable as an argument.

I would normally just create an alias, but BASH doesn't support arguments to aliases. So the workaround for the no-alias-arguments bug is to use a script. No problem. Except the variable I set in the script does not exist when I exit the script.Now, if I run the script by using "$ . myscript" it works in that the variable is set after it exits. The problem is the argument checking I have in the script doesn't work anymore. BASH aliases don't support arguments and I can't export a variable from a script unless I source the script (is it even a script at that point?) Maybe I am simply taking the wrong approach.

View 2 Replies View Related

Ubuntu :: BASH Script Not Recognizing Variables

Jul 25, 2011

I'm trying to write a bash script, and for some reason Bash doesn't seem to like any of my variables _except_ the one used in a loop.What's going on? The same problem with MYS occurs regardless of its name, whether it is declared or referenced before, after, or inside the loop, and whether it is a string, integer, or floating-point number. Also, as far as I can tell, everything related to Bash is up to date.

View 7 Replies View Related

Ubuntu :: Variables In Bash Alises Not Working With 11.04

Jul 26, 2011

I am trying to use the following bash alias:

I've been able to get this working under mac and solaris.

I've also tried not escaping the vars.

Anyone know if this is doable with ubuntu's bash shell? (or any meaningful workaround other than writing a script for this?)

View 2 Replies View Related

Programming :: Python: Using Strings To Run Commands In Os.system('')

Jun 20, 2011

I was zsync-ing the latest Ubuntu 11.10 Alpha and thought I'd make a little GUI for it as a small project. The gui is set up, I just need to figure out how to run zsync with content from to variables, cto and cfrom. I tried the following code:

[Code]....

View 4 Replies View Related

General :: Referring To Variables In Bash?

Sep 13, 2010

Is there a difference when variables are referred to as $variableName and ${variableName} in bash?

View 1 Replies View Related

Ubuntu :: Assign Values To Bash Variables From A File?

Jun 9, 2010

Is there an easy way to get a line from a text file into a variable in a bash script?

I have a file called outside_temp that has a single number, say, 63.2

I would like to make a variable in a BASH script have that value.

I know how to use the input redirection and reassignment of stdin using code...

View 1 Replies View Related

Ubuntu :: Bash ${variables} : Replace Last Instance Of Regexp?

Mar 10, 2011

I have something like...

Code:
var=beer
# echo ${var/%e/E} doesn't do anything because i can only replace "r" or "er" this way

[code]....

View 1 Replies View Related

Ubuntu :: Cron Ignores Bash Script Variables

May 4, 2011

I have a personal server and a dynamic IP address, so I wrote a script to check the currently assigned IP address and compare it to the one stored in a file from the last check, and visit the update URL if it's different.

View 4 Replies View Related

Ubuntu :: Bash Script With Variables Assigned To Path

Jul 7, 2011

I am trying to create a file, that has a variable assigned to it, in another directory. For some reason when I run the script it creates the file only in my pwd and I cannot for the life of me figure out why.My pwd at the moment is Desktop but it does not matter as I have tried from elsewhere. I have tried the touch command in the following ways (some will be obviously incorrect but I was desperate)and many more as well as the original format listed.

View 1 Replies View Related

Programming :: Python: Commands.getoutput (command) Fails

May 26, 2010

I've writte a small Munin plugin using python, which basically runs a shell command, and write the output to a file. For some reason the script fail quite often, and it seems to be failing at the "commands.getoutput" statement. This is what's leading up to that statement:

[Code]..

View 4 Replies View Related

Ubuntu :: Adding Strings To The Front And End Of Variables In Bash Scripting?

Mar 3, 2010

How do you add strings to the front and end of variables in bash scripting? for example, if I have

Code:

in as the contents of my variable, I want to add "l" to the front and "k" to the back of the contents.

View 1 Replies View Related

General :: Join 2 Variables In A Bash Script?

Aug 12, 2011

I have $db and $DATE set in my bash script, then I need to join them like this: mysqldump --user=usr --password=pss --databases $db | gzip > /backups/sqlNew/$db_$DATE.sql.gz;

Unfortunately, that doesn't work. How do I properly join those 2 variables into a filename?

View 1 Replies View Related

Programming :: Using Grep / Variables In Bash Script

May 10, 2010

I'm trying to write a bash script and I'm having trouble with it.I have a list of DNS entires from a file called zoneExport.txt.Than I want to parse a log file to see if that DNS entry has been queried for. So I'm running a grep command and trying to save it into a variable. What I'm looking for is a variable ($varGrepQ) that has the number of matches for the grep query. I will then run this through an if statement and do some things from there..

But my problem right now is with this grep query. It keeps outputting '0' even when I know there are records in that file and when I run the same query on the command line I get the actual count. My thought is that the $record variable is not passing right.

View 4 Replies View Related

Programming :: Counting Variables In Bash Script

Nov 13, 2010

If I read in variables entered by the user, how can I check to make sure the correct number of variables were entered? For example, after reading in a data file and making it into an array, I have:echo "To check the data, enter the first element number, last element number and step size as x y z:"read x y z.It then goes on to start a loop, but what I would like now (before the loop) is a check to see if three variables have been entered, before the rest of the script continues.

I've tried specifying the variables as $1, $2 and $3, but if I echo $#, the value comes out as zero, so it's obviously not working.

View 9 Replies View Related

General :: Declare Global Variables In Bash?

Jan 23, 2010

I have a problem with a very big script I wrote in bash, and now I need to modulirize it in at least four smaller scripts. The problem is, that most of the variables I have will need to be shared by all scripts.

My question is: is there a way to declare global variables in bash? So that I can use and change them in any of the scripts and every change in the variable can be "seen" by the other scripts later.

View 4 Replies View Related

General :: Dynamic Variables And Heredocuments In Bash?

Apr 4, 2011

I've created a script that put in dynamic variables the value HELLO 1, HELLO 2 HELLO 5. And I put the values of this variables in the file text.txt. Here's the script:

Code:
for i in $(seq 1 5); do eval ${i}=$(cat << EOF "HELLO" $i EOF); done
cat > text.txt << EOF
$1
$2

[Code]...

View 1 Replies View Related

General :: Possible To Pass JavaScript Variables To Bash?

Apr 18, 2011

Can I pass javascript variables to bash script? If possible in bash script what code should I insert to receive javascript variables.

View 14 Replies View Related

General :: SQL Command Output To Bash Variables?

Aug 2, 2010

I would like to run a bunch of SQL commands from mysql client in bash. However, I would like to store the output in different variables. E.g.

Code:
var1=`mysql -u[user] -p[pass] -D[dbname] -e "Query1"`
var2=`mysql -u[user] -p[pass] -D[dbname] -e "Query2"`

[code]...

View 5 Replies View Related

General :: Concatenate Two Environment Variables In Bash?

Nov 9, 2010

How do I concatenate two environment variables in bash?

View 3 Replies View Related

Software :: Bash Scripting And Integer Variables?

Jun 6, 2010

Are there numerical variables (like type int in C) in the shell script language of bash? Say I want a counter to increment each time a loop is traversed.

View 1 Replies View Related

Programming :: Bash: Making A Variable Out Of Two Other Variables?

Mar 18, 2010

I need to find the value of:

Code:
$Namenumber
My script asks for the name you want to look up and I want it to return the value of $Namenumber

I was thinking:

Code:
number=$"$name"number
but this returns

Code:
$Namenumber

but does not actually resolve what the variable $Namenumber is equal to.

View 4 Replies View Related







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