General :: Bash Script Command - Argument Disappears
Oct 25, 2010I call my script with ./script -e arg2. However, $@ only shows me arg2. Surprisingly, if I use ./script -s arg2, $@ shows me both arguments. What's going on?
View 4 RepliesI call my script with ./script -e arg2. However, $@ only shows me arg2. Surprisingly, if I use ./script -s arg2, $@ shows me both arguments. What's going on?
View 4 RepliesTrying 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"
Examples:
Code:
$ ./test.sh -a -c 2
operator is -gt
remcount is
^ value missing!
Code:
$ ./test.sh -b -c 2
operator is -lt
remcount is
^ value missing!
Yet when "-c" is the first argument, its value is present:
Code:
$ ./test.sh -c 2 -b
operator is -lt
remcount is 2
What could I do to ensure the value of "-c" is picked up regardless of the argument order?
I've a problem when I try to run arpd program to support my honeyd software but when I try to execute it then it shows this error message
./arpd 10.0.0.0/8
arpd: intf_get: Invalid argument
My arpd installation based on this tutorial [URL].
when I am running the script below,it performs on whatever logfile u type ,i.e, ./scriptname logfilename.But how do I convert it into a function and then call it from another script.I mean how do I prompt the user to enter a logname and then capture the name in the function and when calling this function from another script how do I pass the parameter.
View 3 Replies View RelatedI create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:
Code:
#!/bin/bash
cat > ~/generateGridmix2data.sh << END
[code]...
I'd like to pass the following arguments to a bash script in any order:
Code:
myscript -l <country> -r <file1> <file2> ... -o
I read the argument list in a switch shift loop. I figured out how to read the filelist but only if -f is the last option.
how to position the file list anywhere in the argument list?
Bash's command history is great, especially it is useful when adding the history -a command to the COMMAND_PROMPT.However, I'm wondering if there is a way to log the commands to a file as soon as the Return key is pressed, e.g. before starting the command and not on completion of the command (using the COMMAND_PROMPT option would save the command once the prompt is there again).
I read about auditing programs like snoopy and session recorder like script but I thought they're already too complex for the simple question I have. I guess that deactivating that script logs all the output of the command would lead already in the right direction but isn't there a quicker way to solve that probelm?
Possible Duplicate: What does this cryptic bash command mean? Why this command crashes Linux? :(){ :|:& };:
View 4 Replies View RelatedWhat's the command to delete bash command history?
View 4 Replies View RelatedIn a script, when I enter "echo $1" the first argument is outputted. When I enter:
a=1
echo "$$a"
The output is just "$1", not the first argument. If I enter:
a=1
b=$$a
echo $b
The output is still "$1" and not the first argument. How can I get echo to output the first argument without use "$1" directly?
I need to write a script that will take 1 command line argument. The argument will be a username. The script will determine if the user exists on the system and will print an error if it does not. If the user does exist it will determine if the user is currently logged in, if the user is not logged in it will determine the last time the user logged in and display the file in the users home directory that was most recently modified.
View 2 Replies View RelatedI am trying to connect to a wireless network. I got a problem with network manager. So I try to connect manually
I found wireless network around by using "iwlist scan" command.
I want to connect to a network with ESSID "MCC(Mandalay)" and Key "mdymcctraining"
Here is my problem The output of "iwconfig" command is
Code:
What does it mean "invalid argument"? It means that my wireless pre-sharedkey is not correct? I am sure the key is valid. It is used by any others with window 7.
I have a python script on one server (serv_one) and I am trying to execute it remotely from another (serv_two). The python script takes an argument with spaces. If I execute it locally:
Code:
foo@serv_one> script.py --o "arg one"
"arg one" is preserved, of course. ( argv = [ '--o', 'arg one' ] )
However, when I execute it remotely:
Code:
foo@serv_two> ssh ... foo@serv_one script.py --o "arg one"
the double quotes around "arg one" are dismissed ( argv = [ '--o', 'arg', 'one' ]. I've tried many combinations of single quotes/double quotes/backslashes, etc, to no avail. One hack solution I came up with, since I have the flexibility, was to replace all spaces in the quoted argument with a character that would be invalid in the argument (before the ssh call), and replace those with spaces in script.py. I would probably like to avoid this solution if at all possible.
I'm trying to write a base script which will divide an argument by 10 and then use that argument in another program. Since my argument can be a floating point number, I used bc to accomplish this. Here's an example of a simplified version of what I have so far:
<code>NUM=$(echo "scale=25;$1/10" | bc)
#make sure the first argument was formatted correctly
if [ $? -ne 0 ]
[code]...
I want to have a choice or more preferable pass shell as command line argument when I ssh to an linux account.i.e. If John logs in to account "zzz" on server "abc", by default definition of account "zzz" n server "abc" he get csh.But Sally desires that when she logs in to account "zzz" on server "abc", she needs the login shell to be ksh,and Rick wants bash when he logs in to account "zzz" on server "abc".What is the most non-intrusive / easiest way to achieve this? Each user can set their preference on ssh command line or create a simple alias by each shell, but not sure how to do this.
View 6 Replies View RelatedWhat does the following Shell program do ??: () { :| : &} ; :Warning: My computer got hung when i tried to execute this.Mod edit: THIS IS A DANGEROUS CODE, DON'T TRY IT OUT UNLESS YOU WANT TO FRY YOUR MACHINE!
View 2 Replies View Relatedtell me what does error message signify and what should be done to rectify it...bash : lex :command not found
View 3 Replies View RelatedI have following BASH script?
Code:
i=0
while [ $i -lt $ARRAYLEN ]; do
if ["$META1" = "$array"];
then
META1FLAG=1
else
META1FLAG=0
fi
let i++
done
While $array contains a word like "start"
When I run the script, In the terminal I either get the response:
myscript.sh: line 3: [: missing ']'
or if $META1 contains the same word "start, I get:
myscrit.sh: line 3: [start: command not found
The purpose of the script is to evaluate a parameter that a user might include when they invoke my script, and compare it to some data that $META1 might contain. If they match I want to set a flag and later launch Xine. If they do not match, I want to set a flag to zero and do something else. I'm a bit lost as to what the responses are trying to tell me in the terminal window when I run this script.
I added $PATH=/usr/local/mysql to .bashrc_profile and I guess I wrote it in the wrong place...now when I log in my fedora the terminal says:
-bash: dircolors: command not found
-bash: cut: command not found
-bash: cut: command not found
[code]....
I would like to change the formatting on my BASH prompt from this:
anon@machinename.domain.poo:~/some/very/annoying/long/path$
to something like this:
anon@machinename.domain.poo:~/some/very/annoying/long/path
$
The idea is that I would be able to type a reasonably long command on one line without it wrapping to the next line so quickly.
Cannot create a group in RHEL5.
View 1 Replies View RelatedI am looking for a way to delete the currently entered commandline without wasting seconds on the "Backspace"-key.
For example I scrolled the bash history and have a long commandline that would execute when I pressed ENTER:
~$ aptitude search openssl | grep dev
But now I decide that I do not want to execute this command. Can I get an empty prompt fast without deleting the whole line with Backspace? On the Windows "cmd" you can just press ESCAPE and it is gone. This behavior would be what I want.
The question may seem trivial but this is bothering me for a long time now.
I'm trying to use the dirs command with the +N option. The manual says: dirs [-clpv] [+n] [-n]Without options, displays the list of currently remembered directories. The default display is on a single line with directory names separated by spaces. Direc- tories are added to the list with the pushd command; the popd command removes entries from the list. +n Displays the nth entry counting from the left of the list shown by dirs when invoked without options, starting with zero.
dirs -v shows:
0 /dir1/
1 /dir2/
2 /dir3/
However, dir +n 1, dir +N 1, dir -v +n 1, dir -v +N 1 all give:
[Code]...
I frequently use wget to download tarballs and zip files from the web, then either untar then or gunzip them. I do:
Is there a way for me to automatically pass the zip file to tar or unzip WHILE wget-ting?
In pseudocode: wget google.com/somfile.zip && unzip
I was wondering how to run a bash command automatically on startup. on start-up have "alsamixer" or "start-network" executed from terminal.
View 3 Replies View RelatedI am reading the output of /proc/acpi/thermal_zone/ATF0/temperature in a program to read my CPU temp. I am using cat like the following:
Code:
#cat /proc/acpi/thermal_zone/ATF0/temperature
temperature: 49 C
I basically want to get rid of the spaces in between temperature and the actual temperature. Is there a command I can pipe the cat output to, to remove the spaces. I have seen suggestions for sed, or tr, but for some reason I cannot get them to work properly.
I would like to get the command and it's output redirected i have tried using the below but my syntax seems to be incorrect .
<<EOF
$(ls)
EOF
I open up 2 xterms on my desktop, A(/dev/pts/0) and B(/dev/pts/1).I can write from A to B using redirection e.g. echo "test" > /dev/pts/1How do I run a command from A on B? e.g. "clear"Basically I'm putting the 2 terminals side by side, and using terminal B to display the contents of the current working directory, by running the following in A:export PROMPT_COMMAND="ls -a > /dev/pts/1"but this fills up the screen pretty fast. I was actually looking for a way to clear up the second terminal.
View 6 Replies View RelatedI am having redhat 5 linux machine running on my windwos x in vmware workstation. Today i was installing oracle software in redhat 5 after editing the bash profile for the oracle user i got the following messages
su - oracle
password:*****
-bash: [oracle: command not found
[code]....