hi guys, im trying to understand the bash rules or hash tag rules.
my understanding is the the everything to the right of the bash command is not executed? is this right? and you disable it by using a new line to enter executable commands?
I am looking to display the w (who) command to show only the
User TTY IDLE
http://screencast.com/t/vXb74kguJ
13:15:38 up 8 days, 16:48, 47 users, load average: 1.47, 0.95, 0.51
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
rf3 pts/0 192.168.11.72 05:58 48.00s 6.60s 0.00s -bash
user21 pts/1 192.168.21.177 04:32 8:41m 0.05s 0.00s -bash
user7 pts/2 192.168.11.114 17Mar15 6days 1.07s 0.00s -bash
user7 pts/3 192.168.11.114 20Mar15 4:54m 9.75s 0.00s -bash
user6 pts/4 192.168.11.85 11:02 7.00s 55.58s 0.01s -bash
user14 pts/5 192.168.11.183 05:06 29:08 2.80s 0.01s -bash
user14 pts/6 192.168.11.155 05:30 13:28 2.75s 0.00s -bash
user23 pts/7 192.168.11.62 05:48 25:09 0.95s 0.00s -bash
rf5 pts/8 192.168.11.118 05:58 6:51 5.30s 0.01s -bash
user2 pts/9 192.168.11.140 08:34 1:19 44.74s 0.00s -bash
user14 pts/10 192.168.11.141 06:02 12:14 9.46s 0.00s -bash
rf12 pts/12 192.168.11.69 06:02 2:07 9.44s 0.00s -bash
root pts/13 localhost.locald 12:29 9:10 0.05s 0.05s -bash
rf6 pts/14 192.168.11.79 06:04 14.00s 9.05s 0.00s -bash
user14 pts/15 192.168.21.113 06:23 11:29 1.71s 0.00s -bash
user5 pts/16 192.168.11.126 06:24 6:56 4.59s 0.00s -bash
user5 pts/17 192.168.11.126 06:25 6:19 31.59s 0.01s -bash
user11 pts/18 192.168.11.125 06:26 28:10 2.90s 0.01s -bash
user12 pts/19 192.168.21.123 06:35 13:16 0.88s 0.00s -bash
rf7 pts/20 192.168.11.80 06:35 2:06 7.64s 0.00s -bash
user12 pts/21 192.168.21.123 06:36 41:55 0.12s 0.00s -bash
So far I have this
w | awk {'printf ("6s\ts\n", $1, $2, $3, $5)'} |more
13:20:16 up
USER TTY
rf3 pts/0
user21 pts/1
user7 pts/2
user7 pts/3
user6 pts/4
user14 pts/5
user14 pts/6
user23 pts/7
rf5 pts/8
user2 pts/9
user14 pts/10
rf12 pts/12
root pts/13
This only shows the 2 columns
w |awk '{print $1, $2, $3, $5}'
13:21:01 up 8 16:53,
USER TTY FROM IDLE
rf3 pts/0 192.168.11.72 20.00s
user21 pts/1 192.168.21.177 8:46m
user7 pts/2 192.168.11.114 6days
user7 pts/3 192.168.11.114 4:59m
user6 pts/4 192.168.11.85 3:42
user14 pts/5 192.168.11.183 34:31
user14 pts/6 192.168.11.155 18:51
user23 pts/7 192.168.11.62 30:32
rf5 pts/8 192.168.11.118 12:14
user2 pts/9 192.168.11.140 1.00s
user14 pts/10 192.168.11.141 17:37
rf12 pts/12 192.168.11.69 30.00s
This shows some what hard to read and the columns don't line up correctly
is there a way to tab them in to columns that line up properly, or even something similar to the TOP command where the list will keep refreshing?
I want to write a bash shell script to execute a command for one minute then stop that command (ctrl c) pause for 10 seconds then run another command for one minute then stop that command pause for 10 seconds then go back to the begining of the script and loop indefinetly.
First I want to run this command for one minute;
reaver -i mon0 -c 6 -b "mac address" -a -vv
stop previous command and pause for 10 seconds
Then run this command for one minute;
airodump-ng -i mon0
stop previous command and pause for 10 seconds
Then recall reaver command and continue to loop through until reaver spits out result.
I imagine I will need to create a function for each command, an if statement and an ifelse statement and I will need the break and sleep commands. but I am not sure about the syntax, PLEASE HELP THIS NOOB!
I need to compare a value with different fixed value. Below is the code concept I implemented in my bash script but its giving me error.
Here "a' is the nameserver value that I extract using command line from /etc/resolv.conf. I did not put command here.
#! /bin/bash
a=1.2.3.4
if [ $a == 1.2.3.4 || 5.6.7.8 || 8.9.1.4]
then
echo " You have correct ntpserver"
else
echo"wrong ntpserver"
fi
Am I comparing the value correctly or any suggestion?
Thank you
hi guys
i was taught that /etc/profile was global for environmental variables and settings...and ~/.profile was specific to the user...
and that bash.rc and ~/.bash.rc was for aliases and functions...i was trying to setup a permanent alias in my profile to a common ssh command and read that it should be going into .profile??? is it really not strict or just a rule of thumb?
Apologies. I've been out of Unix for 14 years, and the gears have rusted. Also, Unix has changed - enough similarities to memory that I'm pretty comfy though.
Glad to see lots of info available via google. However changes are going to take getting used to. Have set up a testbed of 3 nearly identical machines, hoping to make an (at home) private network where I can automate installs and set-ups using NIS and NFS (Similar to work I once did).
Have found useful scripts interspersed with comments, would like to copy and paste them to a bash script that:
Reads the line.
Echos the line.
Reads the reply.
Executes what is typed.
Essentially, by making myself type (or copy & paste) the commands I think I'll become familiar.
Figured I'd use a spreadsheet, select the file, and paste into column B of the spreadsheet. In column A I'd paste:
echo "
and in column C I'd paste:
"
Then I'd cut and paste into a text document, insert the lines:
read A
$A
behind every command necessary to the actual task.
Figured I'd have to escape the ' and ".
Ran a test (test.bash):
#!/bin/bash
for i in `seq 1 10`;
do
echo "Enter a command:"
read A
echo "Trying $A"
$A
done
works fine when I type
ls -alg
but not so when I type
ls -alg | grep dwrx
so I'm wondering if someone has a suggestion?
Thanks for any ideas.
Hi,
I am working with a software that is based on Perl scripting and I have encountered with a bash scripting error. So as I am not familiar with bash scripting well, I don't know how I can solve.
sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: ` 32(andRlooks_unw'
It should be mentioned that my $SHELL is /bin/bash. Could you please guide me what '-c' is? where is it? if I change the shebang (the #!/bin/sh part) to #!/bin/bash, the problem will be solved?
Regards,
Zahra
I am trying to understand what | bash -s does
$ echo ls| bash -s sdfdsf <--- seems to be same as $echo ls |bash . What is the -s asdf doing?
Hi,
I have Redhat 5.3 running on my machine. But when I am login through putty it gives me below error.
Without running any grep command I get this error on login and the grep command doesn't work.
login as: root
root@IP's password:
Last login: Mon Feb 16 15:27:55 2015 from IP
-bash: /bin/egrep: cannot execute binary file
-bash: /bin/egrep: cannot execute binary file
-bash: /bin/egrep: cannot execute binary file
-bash: /bin/grep: cannot execute binary file
-bash: /bin/grep: cannot execute binary file
[root@bkpdrill ~]# grep MemTotal /proc/meminfo
-bash: /bin/grep: cannot execute binary file
hello
first year of learning linux and bash script
Now i wrote a bash script with a function.
Today i recieved a email from my teacher that 1 function only can have 1 command and no more then 1?
thats a part of the script
Code:
function tx_unreachable_msg()
{
LOGLINE="[$DATE] no ip service unreachable"
typewriter "$NOIPSERVICE niet bereikbaar" .1
sleep 1
typewriter "Mail wordt verzonden naar $email" .1
mail -s "NO ip mail error" "$email"<<EOF
dynupdate.no-ip.com niet bereikbaar @ $DATE
EOF
}
it's part dutch part english but the point is that the first LOGLINE is forbidden in the function because i use the functie to send a mail end not to write a logline but that's a part of the command in my case?
So what does this function?
If the no ip service is unreachable then it's write to /etc/var/log/no-ip and after the sleep it's send a simpel mail to the adres in the variabele mail.
i read here at the first line:
Quote:
Shell functions are a way to group commands for later execution using a single name for the group.
so is it true that my function is wrong and so no can someone point me to a website where it's say that more commands are allow in 1 function0
grts b
Hi all,
So ever since I installed livestreamer yesterday, oftentimes when I execute a command in bash it seems to be executing livestreamer and treating everything I actually entered as arguments. For example, I will type
sudo emerge -cav livestreamer
and I will get an error messaging advising me not to run livestreamer as root.
This seems to happen 100% of the time when the command I intend to issue refers to livestreamer in any way, and only some of the times when it doesn't.
I'm pretty new to linux, and I've been able to google my way out of a few problems so far, but this one has me baffled. I've checked my bashrc file for things out of the ordinary, but to no avail. Any and all help would be really appreciated. If I've left anything out let me know.