236 Posted Topics
Re: Sent you PM on this site since I don't use MSN. Cheers! , Mike | |
Re: Hey There, I'm not sure what you're looking to do over time (since you'll have to deal with leap years, etc), but the two things I found in the script were the way the "if" statement was setup and the assignment for the "month" variable. I rewrote it very quickly … | |
Re: Here you go :) Use the file extension as the only argument [CODE]#!/bin/ksh ext=$1 for x in `ls -1d *$ext` do /bin/rm -i $x done[/CODE] Hope that helps :) Mike | |
Re: Hey there, For the above example - filename generation - you could do [CODE]#!/bin/ksh filename=`echo $0|sed 's/^.*\///'` while read line do new_filename=`echo $filename|sed "s/[0-9]/$line/'` touch $new_filename done <FILE[/CODE] I'm such a lazy scripter ;) Should do the trick though , Mike | |
Re: Hey there, It's hard to tell without code tags, but it looks like you might be using regular ticks when you should be wrapping your expr expression in backticks. Cheers, , Mike | |
Re: Hey there, If that's the default behaviour of your vi, you can put this in a .exrc file in your home directory, but, while you're in the editor, just type [esc]:set prompt If it is that you're starting in command mode and never getting out - hitting i - will … | |
Re: Depending on how old-school you want to get, you can also check out the "expr" command -- It's generally used for arithmetic, but also does string matching - depending on the version it can be pretty cryptic (Gnu is the most intuitive). e.g. (from the manpage for Sun - check … | |
Re: Hey There, I think the problem might be in the classpath definition on the command line: java -classpath ./:./jars/tools.jar:./jars/nexus.jar Since all the paths start with "./" you'd have to be in the directory with the jars subdirectory when you run the install.sh script. That's my first inclination. Let me know … | |
Re: Hey There, Probably this would do the trick - not elegant but should work: [CODE]#!/bin/ksh while read line do awk -F"@" '{if ( $0 ~ /@/ ) print $2}'|awk -F"," '{print $1}' >>file.tmp done < INPUTFILE sort -u file.tmp >>output rm file.tmp[/CODE] Best wishes :) ,Mike | |
Re: Hey There, I'm not sure if you want to create input files or parse input files to put into excel spreadsheet format. If you want the output to be continuous, is each continuous output segment going to be a cell in excel? Just curious. It's easy enough to grab the … | |
Re: Hey there, This should work in sh/ksh/bash, etc - incrementing up to 60 [CODE]number=1 while [ $number -le 60 ] do let number=$number+1 >>outputfile.txt done[/CODE] Best Wishes , Mike | |
Re: Hey There Maybe this would help - not in front of a terminal right now, but this should be close if it's not right, I hope :) This assumes that you're only reading in one file with one store.. extrapolate as necessary [CODE]store=0 while read line do if [ $store … | |
Re: Are you using gnu make or the one that comes with solaris? I think your issue might have to do with what "make" you're using Best wishes, , Mike | |
Re: Hi, I'm not sure I follow on the first one, but for the second part, this might help: $already_putin=2.00 # use 0 to start; $input = 1.00; $mean_average = ($already_putin+$input)/2; [QUOTE=kahaj;482432]I'm writing to a file. There are only ten items able to be written to the file (game scores, test … | |
Re: Hey there, if you're running Solaris and not using "sneep" (which requires you to input the serial number manually), there's no way to get the serial number off of the box without looking at it - not even through the ALOM, although they're supposed to be adding a feature like … | |
Re: Change this [CODE]#!/bin/bash while (x < 101) { ./<filename> & x++; }[/CODE] To this and you should be good [CODE]#!/bin/bash x=1 while [ $x -lt 101] do ./filename & let x=$x+1 done[/CODE] The bash tutorial referenced in a previous post is a good read if you're going to be doing … | |
Re: Hey there, can't be too specific because I'm not sure exactly what you're trying to do or what your code looks like. If you want to read the program into a file cat program >file if you want to read a file into the program program <file to encrypt data … | |
Re: Hey There I don't see in the script where the Oracle environment is being sourced into the script. Do you run this on the command line as Oracle when it works? Probably, if you added a line near that top, like: . /home/oracle/.profile The space between the dot and the … | |
Re: If you see "Hello world!" in the browser when you pull up this page, then it's working fine. This isn't so much of a cgi script as a perl script that prints out html. You won't see the #! perl line or any of the print statements. When you view … | |
Re: Hey there, The simplest thing to do, if you're getting the opposite results of what you were expecting, would be to reverse your comparisons if(substr(x[j],1,1)!="0" change to: if(substr(x[j],1,1)=="0" and so on, Mike > Hi all; > > I'm stuck with this simple awk script,i need to group the lines which … | |
Re: Assuming you're running the c++ code from within a script, so that the ENV stays the same, you can just do export SHELL=$A if that's a misunderstanding, you can do this export var=$A Hopefully, I understood what you meant :) , Mike | |
Re: If you're using a more advanced shell than posix or sh, you can use "let" also - just a suggestion :) let var=2+4 echo $var let works the opposite of expr, in so far as the spaces go - you shouldn't put any spaces between operators and operand , Mike | |
Re: Hey There, If this line of code consistently puts a separate distinct line with 1 as the intro line, you can fix your problem the simplest way by just adding a pipe to the end: yourCommandString | sed 1d , Mike | |
Re: Hey There, If your issue is with awk, you could double up on awk (pipe one command to the other) and just change your default delimiter for the one search to the ":" symbol, like: awk -F":" '{print $4}' <-- for example <-- not specific to your script. You might … | |
Re: Hey There, For step 5, ask for user input like in your other steps and then use that information and run "finger" or grep out of /etc/passwd and format as you like. For step 6 - just use cat - I don't know which system log you'd be looking for … | |
Re: #!/bin/ksh cat inputfile.txt|while read v w x do if [ -e $x ] then num_lines=`wc -l $x|sed -e 's/ *//' -e 's/ .*$//'` time_stamp=`ls -l $x|awk '{print $6 "_" $7 "_" $8}'` echo "$v $w $x $num_lines $time_stamp" fi done That will give you output like this (when both files … | |
Re: Just a quick thought: If you use a path, also, it's best to make it absolute (/opt/whatever/go) rather than relative (../go) otherwise changes in your script could change where you try to delete the files from; assuming it's a constant. , Mike | |
Re: Sorry if I misunderstand. /usr/bin/time just returns the amount of time spent processing your request - generally the actual time and how much was spent processing user (software) and kernel (os). With -al, it will show you that - this is probably what you're looking for, but I believe you … | |
Re: Hey There, The simplest way would be to have the first method/function return the result: return 10001 - or return $variable Then call method/function 2 with the return variable from method/function 1 as its argument. do_b 10001 - or do_b $variable Depending on how your shell scopes it could be … | |
Re: Hey there, From the info you've given I wrote this: #!/bin/ksh backupid="hi_there" creation=`echo $backupid | sed 's/^.*_//'` echo $creation and ran it. It returned: _there Do you have more info on it? What would your backupid variable be set to? We're running Solaris 10 on hardware like V245's, T2000's and … | |
Re: This is a stretch, since I'm not in front of linux/unix computer right now, but the error might be at your subroutines. I always do this, so I don't know if it's a problem, but you might try doing: sub convertFromCel, rather than just convertFromCel at the end when you … | |
Re: Hi There, That shouldn't be a problem at all. Depending on what you want to do you can use find to get all files created within the last 24 hours (assuming /home as your current directory): for x in `find /home -mtime 0` do mv $x /cernet/d_p19/ccluserdir/. done you can … | |
Re: Hey There, The last line of your script is actually okay. The error you're getting looks like it's coming from sendmail. Depending on what version you're running you may need to edit /etc/mail/sendmail.cf or /etc/mail/submit.cf and specify the IP of the host in DaemonPortOptions - It's either that or ClientPortOptions. … | |
Re: Hey There, You've pretty much got it. Just an inch away. All you need to do is complete the if-then statement with fi. if [ -e $x ] then echo "file exists" else echo "file doesn't exists" [B]fi[/B] That should do it. Hope that helps :) , Mike | |
Re: Hey There, Assuming you're getting the variables from the command line Ex: script 1 4 38 4 7 ... #!/bin/ksh highest_number=0 for x in $@ do if [ $x -gt $highest_number ] then highest_number=$x fi done print "Highest Number is $highest_number" Hope this helps :) , Mike | |
Re: Hey There, Basically this line of code is just making use of tar's abililty to read and/or write to/from stdout/stdin #zcat compressed_tarball.Z | (cd /export/opt; tar xvfp -) might not always work as expected, though. Here's a solution or two that are more exact and do just the tar move … |
The End.