General :: Shell Scripts Variables Test?
Aug 5, 2010What will be the output of the following Shell Script?
Code:
a="1245"
[-n $a]
[code]...
What will be the output of the following Shell Script?
Code:
a="1245"
[-n $a]
[code]...
in gnuplot it's possible to set the value of a variable via linux shell command.or instance we can do
Code:
a="`echo 1`"
b="`echo 2`"
[code]...
Explain the following unexpected results
$ whereis date
date: /bin/date ?
$ echo $ PATH
[code]...
Ive created some custom shell scripts to run during the kernels boot process (they are called from the init script).I was wondering if there's any way to assign a variable that can be accessed between different scripts.For example my first script checks which type of pc i am installing on and assigns the hard drive location to a variable.HARDDRIVE = "/dev/sda1"at the end of the script it calls another script. In this script I cant reference HARDDRIVE as it is blank, to get around this I need to repeat the same code for assigning it.Its more of a space/aesthetics issue but I figured someone might know the solution off the top of their head
View 1 Replies View RelatedI have been give a task of replicating one of our production systems to create a test system. I have been restricted to use c shell to set up its environment variables. I am new to this my questions is how do i set environment variables for a particular user on c shell e.g ORACLE_HOME and ORACLE_SID permanently for a particualar user i know in bash you edit the .bash_profile file. What do i do for c shell?
View 2 Replies View RelatedI have a user that has been used for long time now that runs o C Shell... now there is a need to change it to Bash Shell? Can I cause a problem changing his shell from C to bash? I mean apps or variables?
View 2 Replies View RelatedI hav a shell script that outputs few variables. i want to output them in a table format. any unix commands?
The output i need is:
I was looking at this line in an init file:
Code:
test -f /etc/default/postfix && . /etc/default/postfix
Which I understand to mean test that files /etc/default/postfix AND etc/default/postfix exist. Two things
[code]....
Cis 140 student.how to use the test command to evaluate whether the shell variable I create contains a referance to the bash shell? and use the echo command to determine the result.
View 1 Replies View RelatedI'm running into a problem when I try to set a variable to an awk output in c-shell. Right now my command is Code: set STR_MSG_TYPE = `awk -F{ '/msg_type/ {print $2}' <filename> | tr -d }'/''*' ` I then run echo to see what the output is and it returns blank, however, when I run the same awk command from the command line, I get an actual output of "MT-715". Am I setting my variable incorrectly? I do something similar using the date command to set a STR_DATE variable earlier in the code and it works fine and I use the same syntax.
View 1 Replies View Relatedi have following code :
Code:
TMPDIR=`mktemp -d`
mkdir $TMPDIR/old/
[code]...
I've got a CGI that I'm trying to debug. Apache gives me an ambiguous 500 error; it would be nice to see the raw output via the shell. I've got the POST request w/headers as follows. What's the best way to troubleshoot this?
POST /cgi/packBoxes.cgi HTTP/1.1
Host: 70.87.60.214
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[code].....
Somehow I'm not really managing this thing, which would d be a nice way to useariables.What I am doing is setting up compound variable in ksh. What I have is a "config" file, which has fields delimited by a semicolon
Code:
cat ${CONFIGFILE} | grep -v "^#" | grep -v "^$" | while read line
do
[code]...
I'm aware that one can export make variables to other makefiles; however, how does one export them to the environment of $(shell)? Take the example below:
Code:
export TEST
VARIABLE=$(shell echo $$TEST)
.PHONY: all
all:
#$(VARIABLE)
In this example, I might call make TEST=test. The goal is for $TEST to be available to the environment of the shell escape. This is because I need its value in a script which is called. For example:
Code:
VARIABLE=$(shell i-need-TEST.sh)My current solution is the following:VARIABLE=$(shell export TEST="$(TEST)"; i-need-TEST.sh) but this only works if I know all if the variables needed at that point (as opposed to being able to export variables in included makefiles.) Is there an easy solution?
I have a question concerning indexing over lists with unix shell scripts. I have very large text files (up to 20 Gb) with the data shown below:
80011412865610
43000216943210
4710510513101
[code]...
I have an RHEL 5 server joined to a windows domain. However I wanted to add variable lines to be executed each time a user logs in. However I succeeded to put them in /etc/bashrc file and it worked like a charm.
But its annoying that everytime the user logs in to the shell remotely it displays the whole variables that were declared. Is there a way how to add them once and not to display the output each time the user logs in?
I'm trying to write a simple shell script, its purpose is not important. The script needs to make use of the system $HOSTNAME environment variable. I had a look at this page which provides the following example.
Code:
#!/bin/sh
echo "You are user $UID on $HOSTNAME"
echo "Your home directory is: $HOME"
echo "$HOSTNAME is running $OSTYPE"
[Code]...
I am trying to modify a script for research purposes and am having difficulty here as I have little prior experience with C-shell scripting.
The script looks as follows (it includes tcl commands like runFEP that you can ignore)
#!/bin/bash
for ((old=1, new=2; old<=4; old++,new++))
a1=${old}%50
a2=${new}%50
do
cat > input${new}.conf <<EOF
${a1}
code....
My question: I keep getting a syntax error when defining my two variables a1 and a2. I essentially need these variables to be
a1 = value of variable old divided by 50
a2 = value of variable new divided by 50
I was trying to write a script, but for some reason I can't test two variables using -gt:
a=`expr $currentSize + 0`
b=`expr $fileSize + 0`
[$a -gt $b]
this is what I get:
[22234534: not found
what is the problem? It seems like I can't check if a variable is greater than another but only if a variable is greater than a fixed number. Is that so? By the way the variables $fileSize and $currentSize exist and $a and $b have a value.
I have ubuntu 10.10 desktop .. and i wanna try The new Gnome shell?
View 4 Replies View RelatedI've searched and read lots about trying to get gnome-shell to run in Virtualbox(v4) with no success on my end. Lots of the posts are outdated and are using Virtualbox 3.
So anyone have any tips or hints for testing the Gnome-shell? (I'd prefer to test in with 10.10 in Virtualbox 4, but am open to upgrading to 11.04 if necessary)
I'm trying to do the following. from a php webpage click on a link, that opens a shell/cmd and runs an open ping to the device. so it must actually open a shell (for linux) or cmd (for windows) and run a ping to the specified ip. Currently i'm running an exec command, but for this i need to wait for the result to be fetched and print it out. I want to monitor it in realtime, by just clickingon the button. How to get this working?
View 1 Replies View RelatedI have created mobility of 20 nodes and vbr traffic using following attached script I executed the file as ns234 vbr.tcl I got the vbr.tr and vbr.nam but I was unable to load the graph using matlab <trgraph> I thought problem with is vbr.tcl script.
View 1 Replies View RelatedSome may recall I recently gave up on bash, rather than give up my programming style.Surely I will have reason to return but that's another story. My little issue now:I am debugging a new [Korn] shell script. I have a function that performs a specialized match on a string and I see that I am able to call that function with no problem, with both of it parameters. The function does not do any print or echo command - it uses "return" for a TRUE (0) of FALSE (1), as is the shell exit code convention. Thus, I have the following test:
Code:
if [[ match_except_release ${PATH_DIR[$LC]} bin ]]
then
[code]....
Trying to create a small script that will read user's input, test if user entered some input and if not display some message or display a text using user's input.
The script is the following but i get an error saying "[: 6: =: argument expected"
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.
I have installed Postfix + Amavisd-new, then I am started all services (and configured main.cf and master.cf to use amavis).
The questions are:
1) I am trying to test antivirus scan using eicar test virus
Code:
And the message is successfully delivered to mailbox with mark "CLEAN" in maillog. But I cant see any attachment using
Code:
Where is my mistake?
2) Should I update clam and how I can do it?
3) Is spamassassin enabled by default in amavis (I have started daemon)?
4) Where configuration files of spamassassin is stored?
I am trying to install mysql 5.1.44..so i downloaded the binary package, i extracted it and then followed the instructions that were in the manual but i keep getting this error when running this command
Code:
scripts/mysql_install_db --basedir=/home/mosty/mysql
the error is
Code:
Installing MySQL system tables...
100315 20:07:27 [Warning] Can't create test file /var/lib/mysql/mosty.lower-test
100315 20:07:27 [Warning] Can't create test file /var/lib/mysql/mosty.lower-test
[code]....
You can try to start the mysqld daemon with:
shell> /home/mosty/mysql/bin/mysqld --skip-grant &
and use the command line tool /home/mosty/mysql/bin/mysql to connect to the mysql database and look at the grant tables:
shell> /home/mosty/mysql/bin/mysql -u root mysql
mysql> show tables
MACHINE: HP Proliant DL260G5OS: SLES 11 SP1kernel: Linux xserver 2.6.32.12-0.7-default #1 SMP 2010-05-20 11:14:20 +0200 x86_64 x86_64 x86_64 GNU/LinuxIt is used as remote xserver in a LAN.I have configured /usr/lib/restricted/bin/.rbashrc with some environment variables but when the users logon in the system finally is executed $HOME/.bashrc and some environment vars are overwritten.
View 2 Replies View RelatedI would like know when it is necessary or advisable to write a shell script instead of shell function ?
View 3 Replies View Related