236 Posted Topics

Member Avatar for leshi

Hey There, I'm not sure if this is the right forum for this question, but I think it is, so apologies to the mods if I'm answering something I shouldn't be. You can do a for loop in windows bat files like this: Format is: for %VAR in (REGULAR_EXPRESSION) do …

Member Avatar for eggi
0
83
Member Avatar for omrsafetyo

Hey There, I'm using FreeBSD 4.1 right now and got it to work by just wrapping the regular expression in quotes. It may be that your shell is interpreting the * character before it passes it to tar: [QUOTE] # tar xvf bin.tar "*perl*" perly perltest.pl[/QUOTE] The example above is …

Member Avatar for eggi
0
164
Member Avatar for mrboolf

Hey There, Inside the double quotes, in your test statement, the single quotes are being treated as literal characters in the value of the filename variable: If you just change [QUOTE]if test -f filename="'$@'"[/QUOTE] to [QUOTE]if test -f filename="$@"[/QUOTE] you should be all set Hope that helps :) , Mike

Member Avatar for eggi
0
152
Member Avatar for k2k

Hey There, You should be good to go with just a little change-up: [QUOTE]cat <<EOF | mailx -s "subject" target@address hello all, this is supposed to be the body of the mail EOF[/QUOTE] Hope that helps you out :) , Mike

Member Avatar for eggi
0
1K
Member Avatar for madankumar

Hey There, How's the script as it stands? Basically you just need to loop around the scp command (highly depends on how that looping construct is executed, based on what you're looking to do) [QUOTE]scp file1 host1:/some/dir/.[/QUOTE] Is the basic syntax to scp the file from the server you're on …

Member Avatar for madankumar
-1
95
Member Avatar for k2k

Hey there, You just need to change the [QUOTE]"$1"="-s"[/QUOTE] to [QUOTE]"$1" = "-s"[/QUOTE] with space on both sides of the = operator and it works well :) Best wishes, Mike

Member Avatar for k2k
0
79
Member Avatar for sjgriffiths

Hey There, I didn't do any speed testing and this is just off the top of my head (seems like there must be a better way using sed or awk), but give this a try. It should work and, hopefully work faster :) [QUOTE]grep -v `cat suplist.txt checklist.txt |sort|uniq -d` …

Member Avatar for eggi
0
137
Member Avatar for programmer321

Hey There, Your results may vary depending on what's running on the port you're connected to. For instance, I don't believe straight-up telnet (port 23) allows for non-interactive here-document scripting. In such instances, you can use other programs like Perl or, probably more easily, Expect to script out a "fake …

Member Avatar for eggi
0
207
Member Avatar for k2k

Hey There, You can use expr's colon (:) notation for string comparison, but it might be easier to read and write to do something with grep, like: echo $1|grep "/" >/dev/null 2>&1 (use -q for Gnu grep and you can avoid the output redirection). then check errno ($?). If it …

Member Avatar for k2k
0
150
Member Avatar for rusman

Hey There, You can use grep (case sensitive by default) to find "Active: Yes", check the value of $? (errno) to determine if the match was successful (0 should indicate a successful match) and then just cat the file and pipe it to sendmail or use the file as input …

Member Avatar for eggi
0
159
Member Avatar for sameer9812

Hey there, cat FILENAME or more FILENAME or less FILENAME , etc. Depends on what you mean and what OS you're using. Best wishes, Mike

Member Avatar for eggi
0
39
Member Avatar for karthick01

Hey there, Isn't all your traffic going through that gateway to get out to the internet (NATted) and internally? Your best bests are, as mentioned above, getting the information from the gateway device or a proxy (if you use one to restrict web acess), or setting up a machine or …

Member Avatar for eggi
0
135
Member Avatar for axn

Hey There, Just as an aside, and not to do with the overall solution: If you use egrep, you can make use of it's extended pattern matching functionality to reduce your command line. For instance: [QUOTE]egrep -v Pattern1|egrep -v Pattern2|egrep -v Pattern3 |egrep -v Pattern4[/QUOTE] could be written as [QUOTE]egrep …

Member Avatar for eggi
0
87
Member Avatar for marcux

Hey There, You can just use the value that you get from your find command by using backticks to assign it to a variable (just make sure that, if you change your find statement, it returns a full path and not a relative one, as that can cause issues for …

Member Avatar for eggi
0
125
Member Avatar for maxmave

Hey There, For sed, you can just specify the line number, like substituting THIS for THAT on line 4: sed 4s/THIS/THAT/ In Awk, I believe you can specify the NR variable to cherry-pick the line. Best wishes, MIke

Member Avatar for ghostdog74
0
351
Member Avatar for linux

Hey there, You can use "mv" for files and directories. Perhaps I'm misunderstanding. Hope that helps :) , Mike

Member Avatar for eggi
0
121
Member Avatar for conandor

Hey There, du is a good command to use to check a folder size. Compare that against your baseline (whatever your "too big" limit is) and, at that point, just use rm -rf to remove the contents. You'll probably want to run it in cron if it's a persistent check. …

Member Avatar for conandor
0
87
Member Avatar for k2k

Hey there, I have a feeling I know where he's coming from with his insistence on shying away from csh and starting with sh. Check out the man pages for both shells and look for the part regarding "output redirection." At the most basic it's very similar (echo hi >FILE, …

Member Avatar for Salem
0
448
Member Avatar for guest7

Hey There, I'll check this out. What are you trying to delete and what are the spec's for deletion? For the code you posted, you're missing a closing "done" for the outside while loop. It's perfectly okay to do a while loop within a while loop, I'm just thinking it …

Member Avatar for eggi
0
369
Member Avatar for tanha

Hey There, Bash doesn't natively support sockets programming, like in Perl. Are you looking to write a bash script that runs a separate "http server" program? Also, if you've already gotten started, can you post that. This way anyone who checks this post will know where you're at and can …

Member Avatar for eggi
0
185
Member Avatar for sjgriffiths

Hey there, If you need to be more generic (like sometimes you want to match the first 3 letters and sometimes 2, etc) you can use expr's : (colon) operator to do string and substring matching. Hope that helps, Mike

Member Avatar for eggi
0
68
Member Avatar for geofoxer

Hey There, You should be able to modify the polling script that comes with nagios. Other than that, if you wouldn't mind posting your code and notate where you want to set variables, etc, I'd be glad to help if I can. Here's a link to a good [URL="http://steve-parker.org/sh/sh.shtml"]Bash Tutorial[/URL] …

Member Avatar for eggi
0
176
Member Avatar for DimaYasny

Here's another good [URL="http://steve-parker.org/sh/sh.shtml"]Tutorial Linkl[/URL] . It has a section at the end with practice questions, assignment, problems, etc Best wishes, MIke

Member Avatar for eggi
0
131
Member Avatar for k2k

Hey there, You can also place it in a directory in your PATH, after you make it executable, so you can run it from anywhere. I dont' recommend adding a dot to your PATH, but just do echo $PATH and copy your script into one of those directories and you …

Member Avatar for eggi
0
161
Member Avatar for guest7

Hey there, You can also do it this way [QUOTE]sed -e :a -e '$d;N;2,3ba' -e 'P;D' s27.cnf >f2.cnf[/QUOTE] Just change the 3 to hower many lines you want to delete from the bottom Best wishes, Mike

Member Avatar for eggi
0
88
Member Avatar for k2k

Hey There, Check this page for all the options: [url]http://linux.about.com/library/cmd/blcmdl1_ed.htm[/url] As for the insert mode, it's the same as vi. i will put you in insert mode at the position you are, and "a" will put you in insert mode right after your position in the file. You can exit …

Member Avatar for eggi
0
89
Member Avatar for saurya1979

Hey There, I'm not 100% sure on this one, but I believe that "exit 0" or "exit" with any number afterward, causes the shell to exit, while exit(0) is a shell built-in that causes program termination. Generally, your program is running in a subshell that will terminate when your script …

Member Avatar for eggi
0
136
Member Avatar for chris5126

Hey There, You can try emacs for Unix/Linux and Cygwin Linux. I believe there's a windows Emacs out also. if you're a vi(m) guy, they have that for Unix/Linux/Cygwin, also, plus a port to Windows called gvim. Hope that helps :) , Mike

Member Avatar for chris5126
0
153
Member Avatar for sjgriffiths

You can also use the -u flag to sort, which can pick out fields: sort -t, -u -k2,2 -k4,4 Best wishes, Mike

Member Avatar for eggi
0
75
Member Avatar for Raghavansat

Hey There, Maybe a simpler way, but parsing that execution in perl would make for a really simple pattern match on which you could act: if ( $whatever =~ /\/usr\/bin\/java$/ ) Hope that helps steer you in the right direction! , Mike

Member Avatar for eggi
0
79
Member Avatar for karthikvela

If you want to make yourself crazy, but learn alot about regexp in the meantime, use a bash script with sed and awk to extrapolate all the info. Basically, you're just looking to match and extract, so it can be done. Per the post above, you could save yourself a …

Member Avatar for eggi
0
110
Member Avatar for k2k

Hey There, Just a small comment. If you have /sbin/shutdown, you can run it with -h to stop your system, also - just leave out the -r and your system should shutdown and halt. Best wishes, Mike

Member Avatar for k2k
0
565
Member Avatar for pichels

Hey There, You can print out the name of the found file by printing out $0 and the number of characters by printing NF -- You'll be doing both within the awk statement and it's important to print NF for the number. If you print $NF you'll get the value …

Member Avatar for eggi
0
187
Member Avatar for rppprez

Hey There, I'm not much of a windows programmer, but if you can do it in Linux, you should check out Cygwin (about as close to having real Linux on Windows as you can get - at least for free). You can download it at cygwin.com Enjoy :) , Mike

Member Avatar for eggi
0
51
Member Avatar for cyberman111

Hey There, To convert Celsius to Fahrenheit, multiply by 1.8 and add 32 degrees. Hope that helps you get where you're going.

Member Avatar for Impact4ever
0
826
Member Avatar for yasar_ok

Hey There, If the account can login directly to all your boxes, all you need to do is create one script to add a user, or users, and then setup ssh-keys (or whatnot) and run script in a loop through all the hosts. Worst case, if you can't setup key-or-trust-based …

Member Avatar for eggi
0
79
Member Avatar for rysin

Hey There, Are you having problems modifying a variable you declare outside of the loop? This code will increment the variable in the foreach loop and change it's value outside the loop. Let me know if I'm misunderstanding you :) Best Wishes, Mike [CODE]#!/usr/bin/perl $fancy=0; print "BEFORE $fancy\n"; @loop = …

Member Avatar for rysin
0
115
Member Avatar for k2k

Hey There, Check and see if /etc/network/interfaces file is set up, and how. You should just need this in there to do DHCP auto eth0 iface eth0 inet dhcp assuming eth0 is your NIC. You can find out the name (if it's different) running: ifconfig -a and check netstat -nr …

Member Avatar for eggi
0
122
Member Avatar for krdgopinath

Yes, sort with Gnu does give different results. Also, if you need to, try using the -t option if you need to specifically identify the delimiter that your cells in the csv file are being separated by. It could be that the default IFS (one or multiple blank spaces) doesn't …

Member Avatar for eggi
0
94
Member Avatar for baku

Hey There, Can you post the code you have so far and I'm sure someone who cruises these boards will be able to help you figure out how to make it work (or make it work better :) Best wishes, Mike

Member Avatar for baku
0
64
Member Avatar for moazzam

Hey There, Just change this [CODE]x=`echo c:/test.txt | sed -e 's/\//\\\//g'`[/CODE] to this [CODE]x=`echo "c:/test.txt" | sed -e 's/\//\\\\\//g'`[/CODE] assuming you want $x to equal: c:\/test.txt Hope that helps :) , Mike

Member Avatar for eggi
0
90
Member Avatar for cyberman111

Hey There, You could just script out a simple cat from both files and redirect the all the output to a new one as part of the script. Best wishes, Mike

Member Avatar for ithelp
0
117
Member Avatar for The Dude

That was HILARIOUS :) Much better than the full studio version ;) Thanks for posting that! , Mike

Member Avatar for eggi
0
64
Member Avatar for madhura09

Hey there, What error do you get when you try to use javac? Also, is your JAVA_HOME variable set, and $JAVA_HOME/bin in your PATH? Thanks :) , Mike

Member Avatar for eggi
0
105
Member Avatar for ashik_h2k

Hey there, Assuming permissions are lax enough, any user can user "find" or "locate" (on Linux) if they know the name of the tool. Otherwise, all the commands, like "which" and "whence," etc, rely on your environment path variable. Hope that helps :) , Mike

Member Avatar for eggi
0
99
Member Avatar for vikonava

Hey There, Two things you can try. Can you make sure these entries, and file, exist - or add them if they don't: [ICODE]echo 'pwcheck_method: saslauthd' > /etc/postfix/sasl/smtpd.conf echo 'mech_list: plain login' >> /etc/postfix/sasl/smtpd.conf[/ICODE] You need to run the commands as root, I think, or they won't work. Let me …

Member Avatar for vikonava
0
132
Member Avatar for baku

Hey There, In the lab5.txt file, your script could just do "touch" to create all files instead of echoing " " into them. That way they won't have blank lines at the top. Also, the sort calls should be redirected to other files and then copied back over the originals …

Member Avatar for eggi
0
105
Member Avatar for wonder_laptop

Hey there, YOu'd uses that code in pretty much any program that need to use memory that's shared with another process. Also multithreaded programs use them to help with cpu scheduling. They can also be used to synchronize processes (processor scheduling). Basically, if a program doesn't use mutually exclusive (mutex) …

Member Avatar for eggi
0
107
Member Avatar for sjcomp

Hey There, If you use cvs, it will update the minor revision by default every time you check the code out and check it back in. Ex: [ICODE]mkdir -p /var/tmp/build cd /var/tmp/build cvs co PROJECT_NAME cvs update -q <--- if you have this directory already and just want to update …

Member Avatar for sjcomp
0
104
Member Avatar for skelly16

Grepping and sorting should do it for your script. It looks like the file you have a blank space in is already assumed to exist in this script (doesn't get created in it). Do you know what other script (or program) creates the file? That might be the easiest way …

Member Avatar for eggi
0
163

The End.