General :: Use A Global Variable To Apply A Condition Within A Script
Feb 28, 2011
I'm trying to use a global variable to apply a condition within a script.
The idea is to use this variable set to e.g. 1 or 2 to run a different part of the script accordingly. I can set the global variable with e.g.
Code:
export WL0=1
run my part of script, increment it by 1 with e.g.
Code:
WL0=$((WL0+1))
but if I re-run the script my WL0 is still set to 1!
I've also tried to add an
export $WL0 at the very end of my script (after the math) but this doesn't change the global variable apparently.
View 15 Replies
ADVERTISEMENT
Feb 17, 2011
how to assign a local variable value to a global variable....
View 2 Replies
View Related
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
Sep 17, 2009
I'm trying to implement an assert function similar to:[url]
However, I'm having trouble with file existence testing when the file name has a space in it.
I have distilled the problem down to the following:
This code works as expected, printing 'yes' if '~/test file' exists, and no if not.
Code:
However, this code gives an error.
Code:
The error:
Code:
Which tells me that it is splitting ["~/test file"] into ["~/test] and [file"]. Why? Is there a way around this?
Note that if you simply use a file path without a space, both cases work perfectly. Is this a BASH bug possibly? I just can't understand why the first would work, but the second wouldn't.
View 8 Replies
View Related
Jan 18, 2011
Is the logrotate.conf settings global/apply to what is in logrotate.d/? I have olddir /var/log/old_logs in logrotate.conf but logrotate is not placing old rsyslogs in /var/log/old_logs for logrotate.d/rsyslog
View 5 Replies
View Related
May 26, 2010
Is it possible to create a global struct variable with predefined member values?Only one instance of that struct is ever needed.
View 1 Replies
View Related
Mar 18, 2010
I need to write an else-if condition in a makefile, and though the format is posted on several websites, nothing seem to be working, andI get an error everytime. Could anybody please write a small example with an else-if conditional in a maekefile?
View 1 Replies
View Related
Aug 13, 2010
Is there some way to filter output of command by OR condition in Linux? There is filtering by AND condition with grep in way like:
ls -l | grep "^a" | grep "z$"
That says: list all files that beggins with "a" AND ends with "z" (so there is shorter way to write this: grep "^a.*z$", but it is not matter). Is there some way to perform test by OR condition? For example: files that starts exactly with "xen" OR files that ends exactly with ".rpm". But exactly, not something like:
grep "[xen]{0,3}.*[.rpm]{0,4}"
View 2 Replies
View Related
Mar 13, 2011
I have the following folder structure:
parent
- folder1
- main1.x
- main1.y
[Code].....
So, how can I achieve this?
View 2 Replies
View Related
May 2, 2011
How can I have ELSE condition in procmailrc I mean if the mail was from X and Subject has Y OR .... DO something ELSE DO SOMETHING ELSE. I do not want to use two different conditions for each state I want use just one condition and its ELSE because putting too recipes in procmailrc make it too slow .
View 2 Replies
View Related
May 28, 2011
I am writing a simple shell script where it checks the condition using if condition.
Code:
if [ $name == "JOHN" ] then admin='YES'; fi
if I use like this I am getting below error
[code]....
View 1 Replies
View Related
Apr 16, 2011
I am supposed to create an environment variable with the PRINTER variable, which should resolve to the word sales. Would the command be like this?: env PRINTER - NAME=SALES (is this the command to create that variable with resolving the word sales to it?)
View 3 Replies
View Related
May 31, 2010
I want to ssh and check for a file, I hve came up with following, and its not working,
Is this possible or do I have to do this in a another way.
View 5 Replies
View Related
Jul 25, 2010
can i use the value of one variable to generate a name for another variable? for example i want to use the counter from a "do while" loop to name and define a variable each time the loop executes. for example
objectnames1=`ls -a`
objectnames2=`ls -a`
etc.
i don't have a script yet but each time through the loop i intend to cd to a particular directory and then define a variable containing a list of each object in that directory as values. for the rest of the script to work, each variable generated has to be unique, and i can't think of a good way to accomplish this.
if using a value from one variable to name another isn't possible, can anyone think of a more elegant solution? i know limited syntax but i'm willing to read up...
View 6 Replies
View Related
Dec 27, 2010
I am trying to alter the character position of residue numbers above 999 in a pdb file.The following script is an attempt to:1) Get all unique pdb residue numbers (in column 5) using awk and assign it to a variable i.2) Loop through all the values in $i and if it is greater than 999, shift that number one character to the right using sed.However, the script only manages to alter the final residue numberCould anyone please advise how I can loop through all values in $i and shift it one character to the right?
#!/bin/bash
# Script to alter position of residue number in pdb file for resid above 999
i=$(awk '{print $5}' wt-test.pdb | uniq)
[code]...
View 6 Replies
View Related
Feb 7, 2011
i have squid 2.6 installed on centos i created acl which should apply to this ip range i.e 192.168.1.10-192.168.1.15 and excluded 192.168.1.13 how can i do
View 14 Replies
View Related
Jun 20, 2010
My system has been crashing, and I think it may have something to do with Gnome since the crashes only occur when I'm using it. I checked the log file after a crash and it reported...
Gtk-CRITICAL **: gtk_accel_map_unlock_path: assertion `entry != NULL && entry->lock_count > 0' failed
so I went to the Ubuntu launchpad and searched for it, and here it is. Someone has already submitted a patch and the bug status has been changed to "fix released."From reading the comments, I've learned the fix is only in Gnome 2.30, and Ubuntu 10.04 uses 2.28 (I think, maybe 2.26) (If it is possible to update to a new version of Gnome, please let me know). Luckily, someone also submitted a patch on the bug report as a temporary fix. Unfortunately, I don't know how to apply the patch. I couldn't find much information regarding it online, and the only stuff I did find applied to using Gnome's git hub.
View 1 Replies
View Related
Apr 15, 2011
I have a monitor with oversaturated red (HP LP2475w). I am able to apply ICC profile to various apps like GIMP and Firefox and Gnome. But I'd like to apply it to everything - because e.g. Flash animations in Firefox are rendered by Flash and don't use ICC. So, can I apply it to whole X?
View 2 Replies
View Related
Jun 27, 2011
Let's say you have this structure:
+ directory
-- file1
-- file2
-- file3 -> /tmp/file3
file3 is a link to another file3 somewhere else on the system.
Now let's say I chmod 777 the directory and all contents inside it. Does my file3 in /tmp receive those permissions? Also, let's say we have the same situation but reversed.
/tmp/file3 -> /directory/file3
If I apply the permissions on the file being linked to, how does that effect the link?
View 2 Replies
View Related
Aug 18, 2011
I am trying to compile the iscsi-target software SCST. It wants me to apply a patch to my Linux kernel in order to allow for certain performance gains. The problem is I still new to Linux development. Where do I begin? How do I apply the patch? Do I need to recompile the kernel? I am running Ubuntu 10.04.3 amd64
Kernel version 2.6.32-28-server
View 1 Replies
View Related
Jul 29, 2011
i want to apply this command
Code:
pdftotext article.pdf - | grep DOI
to all the pdf's in a directory and save each line of output to a text file. i.e. i want to collect each line containing "DOI" from every pdf in a text file. I am unable to understand bash scripting enough to write a for loop for this.
View 1 Replies
View Related
Oct 4, 2010
I'm running the latest KDE4 and have gotten used to my Yakuake dropdown console.
The problem is that the global shortcuts in KDE stopped working, which basically makes my whole environment unusable now.
How can I fix this?
I restarted kded as suggested in some forums, but to no avail.
View 1 Replies
View Related
Jul 29, 2010
I am trying to learn more about global expressions and how it is needed in changing stuff in vi and in shell scipting in general.My question is basic:
How can I add a " # " pound sign at the beginning of every line in a file. So if I want to remark out every line in a file, what would be the global expression for that? Is there a global expression cheat sheet?
View 4 Replies
View Related
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
Apr 22, 2010
Is it possible to 'include' a global SSH authorized_keys file?
For example, I have user accounts user1,user2,user3 and my user name is Benjamin. I want to be able to use my ssh key to authenticate as each of these users. I can manually copy my key to each .ssh/authorized_keys file individually, but is there a way to simply include /home/Benjamin/.ssh/global_authorized_keys in each of these user's authorized_keys file without manually adding and removing?
View 2 Replies
View Related
Feb 19, 2010
I have two major issues, and one minor one, after I started using Ubuntu, I tried searching the forum for them, but couldn't find anything relevant to my problems.First issue: Screenshots and the cursor.This is probably a very easily fixed issue, but none-the-less, I can not figure it out.How do I NOT include the cursor in my screenshots on Ubuntu 9.10?What I do is, I press the Prt Scrn button, and my cursor is always there in the image, and I don't want that.Second is pidgin.I love it, but every time I boot it up, my friendly name is reverted back to firefoxfag.I think it has something to do with me using gmail for msn, but I'm not sure...Also, as a last very small issue, the global hotkeys on audacious don't respond unless i open preferences, open settings for global hotkeys, then close down the settings..
View 4 Replies
View Related
Aug 4, 2011
On my Ubuntu 11.04x64 server, I have service accounts running which do not log in and do not have home directories. These service accounts are responsible for running processes which are invoked as services.When these services created new files, I need them to be created with the permissions 664 (UMASK 002).I edited the /etc/profile umask setting to reflect this. I see that now my user account creates files which reflect this new umask setting, but the service accounts do not when I manually created files using their accounts (sudo -u serviceaccount touch newfile).
View 1 Replies
View Related
Apr 3, 2010
my linux box the device node for my printer is by default setup as the following: crw-rw---- 1 root lp 189, 1 Apr 3 07:45 /dev/bus/usb/001/002 This causes cups to not print at all. The Hp backend (HPLIP) fails because of these permissions. How do I change it so that it's crw-rw--rw 1 root lp 189, 1 Apr 3 07:45 /dev/bus/usb/001/002. Ie I would like 666 file permission on that node.
View 2 Replies
View Related
Jul 16, 2011
I'm trying to emulate behaviour I get from KeyRemap4MacBook on Mac OS X. It lets me remap control-m to Enter, for instance, globally. Is this possible with X/GNOME? Seems like xmodmap is not suitable for remapping key combinations. I tried xbindkeys to bind control-m to xdotool key Return, but it emits control-return. I tried xdotool keyup control; xdotool key Return; xdotool keydown control but it stills behaves unpredictably.
View 1 Replies
View Related
Apr 7, 2010
I am tech support engg. Provide support for its software which runs on Linux and Windows. Actually I got stuck in installing PHP in my RHEL server. I redirected to this forum, so I registered here. Looking for some URL to global repository which I can use. Lots of dependencies are missing in my repo.
View 2 Replies
View Related