236 Posted Topics
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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 | |
Re: 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 … | |
Re: 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 | |
Re: 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` … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: Hey there, You can use "mv" for files and directories. Perhaps I'm misunderstanding. Hope that helps :) , Mike | |
![]() | Re: 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. … ![]() |
Re: 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, … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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] … | |
Re: 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 | |
Re: 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 … | |
Re: 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 | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: You can also use the -u flag to sort, which can pick out fields: sort -t, -u -k2,2 -k4,4 Best wishes, Mike | |
Re: 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 | |
Re: 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 … | |
Re: 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 | |
Re: 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 … | |
Re: 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 | |
Re: Hey There, To convert Celsius to Fahrenheit, multiply by 1.8 and add 32 degrees. Hope that helps you get where you're going. | |
Re: 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 … | |
Re: 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 = … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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 | |
Re: 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 | |
Re: That was HILARIOUS :) Much better than the full studio version ;) Thanks for posting that! , Mike | |
Re: 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 | |
Re: 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 | |
Re: 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 … | |
Re: 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 … | |
Re: 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) … | |
Re: 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 … | |
Re: 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 … |
The End.