Software :: Changing Variable Name Breaks Bash Script - Find: Unknown Predicate `-maxdepth 1'
Oct 28, 2010
I'm not sure if I should post the whole script here (60 lines) but the script has a variable that occurs only three times, once when it's set and twice when it's referenced/read/expanded (not sure of the correct terminology)Anyway if I change the name of this variable from "maxdepth" to "findopts" the script throws the following error:
find: unknown predicate `-maxdepth 1'
But if I change the variable name to "maxIdepth" it still works? Here are the lines that this variable appears in:
maxidepth=('-maxdepth 1');
.
# other code, etc
[code]....
View 4 Replies
ADVERTISEMENT
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
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
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
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
Jul 27, 2010
I have been using tcsh for quite some time, both on a laptop running Ubuntu and a remote server running Slackware 11. No problem whatsoever. Now I am compiling and installing tcsh on a brand new Slackware 13 box and when I run tcsh I get this error:
Unknown colorls variable 'ca'
or
Unknown colorls variable 'hl'
I didn't have this problem in Slackware 11, why is it happening now?
So I tried the official Slackware package for tcsh. It works, but it's tcsh 6.15.00. Tcsh is at 6.17.00, which runs fine on my Slackware 11 box.
I investigated the problem on Google and all reports seem to refer to Fedora, some to Mandriva. Many of the threads, across several forums and sites, point to this LinuxQuestions thread:
[URL]
View 2 Replies
View Related
Dec 6, 2010
I ran across some odd behaviour using ssh in a bash script. I am hoping someone can explain it to me. I have a file called /home/user/hosts.
Code:
$ cat /home/user/hosts
host1
host2
host3
What I want (for this example anyway) is to run a script that checks this file and for each entry in this file it should log into that host and run a command. I have a script called testssh.sh.
Code:
$ cat /home/user/testssh.sh
#!/bin/bash -
somefile='/home/user/hosts'
[code].....
The oddity that wasted an hour of my day and the question I have for this group is, what is it about ssh that breaks the while loop? It obviously runs through once and checks the first host, just never checks any of the others. I checked exit status's and all kinds of verbose data and I could not figure it out.
View 3 Replies
View Related
Feb 4, 2010
I'm running Ubuntu 8.04.4 LTS to host a moodle server in a school.. moodle is running OK - but I'm having problems with MySql Any mysql command generates:
unknown variable 'pid-file=/var/run/mysqld/mysqld.pid'
I've taken a look in unknown variable 'pid-file=/var/run/mysqld/ and there is no mysqld.pid file I have followed these instructions that I found elsewhere:
If there�s no mysqld.pid inside /var/run/mysqld directory, create mysqld.pid
# cd /var/run/mysqld
# touch mysqld.pid
[code]....
But after reboot the mysqld.pid file is missing again.. I can access mysql via phpmyadmin - but webmin fails with unknown variable 'pid-file=/var/run/mysqld/mysqld.pid'
View 8 Replies
View Related
May 12, 2010
In a c program the value of an integer variable is changing rapidly. I have to get the value of that variable at a particular instant from another program. How can i do it without using a file?
When i tried with extern variable as
I execute the both .c file from 2 terminals but got only value 0 printed for both var_a and var_b all the time .
View 4 Replies
View Related
Jun 8, 2011
I changed shells for a user from bash to tcsh using this command... chsh user -s /bin/tcsh but when logging on via ssh under that user I get a "Illegal variable name" error. I type, echo $shell and it says, /bin/tcsh. I am curious what that Illegal variable name could be.
View 3 Replies
View Related
Apr 30, 2011
I want to make change to environment PATH system wide. Because I have program called "md5". I want to execute it from anywhere (i.e any directory).
My md5 program is located at "/home/ahuq/MappingServer/md5_program". So what I did was to put: "export PATH=$PATH:/home/ahuq/MappingServer/md5_program" in the running SHELL.
This only makes temporary changes and lets me run the "md5" program from anywhere temporarily.
But I want to make this change permanent. So what I did was to put the "PATH=$PATH:/home/ahuq/MappingServer/md5_program" line into the "/etc/environment" file.
This screwed everything up and then for a while I couldn't execute anything from SHELL. I knew the absolute path of "nano" editor and used it to modify the file (i.e. /etc/environment) back to its original condition.
This fixed the problem and now I can run programs like "ls" from the SHELL.
But still I need a way to permanently add the path of "md5" to the environment. How can I do this in Ubuntu 10.10? Which file needs to edited?
Do I just logout or do I have to restart the system to make the changes active?
View 6 Replies
View Related
Sep 30, 2010
'readonly HISTFILE'
but the user could tamper with the histfile itself. Like:
rm -f $HISTFILE;
rm -f $HISTFILE; mkdir $HISTFILE;
rm -f $HISTFILE; ln -s /dev/null $HISTFILE;
I'm experimenting with PROMPT_COMMAND to execute a command each time the user executes a command and so log it somewhere else.This post was pruned from the 2009 Is there a way to prevent users from changing or unset their HISTFILE variable? thread. Please do not resurrect old threads but instead create your own (and maybe provide a link to the old one).
View 2 Replies
View Related
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Apr 22, 2011
I'm using a simple Bash script to export an environment variable, eg.
Code:
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/my/own/dir
[code]....
View 2 Replies
View Related