236 Posted Topics

Member Avatar for Impact4ever

Hey There, That's a tough one, especially since it would vary hugely depending on what version of Linux or Unix you're using and the hardware, etc. I don't know if it'll do it, but you can check out a program called "lshw" that's freely available (and already in rpm format …

Member Avatar for eggi
0
63
Member Avatar for vishwajit

Hey There, You can do it if your implementation of passwd accepts input from STDIN. Just run through a while loop, like [CODE]while read input do passwd code here done <input[/CODE] Hope that helps :) , Mike

Member Avatar for eggi
0
92
Member Avatar for cyberman111

Hey There, Do you have a skeleton of a script. Just whatever you tried that isn't working? If you post that here, more folks are likely to respond and get you to the answer you need quickly. Best wishes, Mike

Member Avatar for Impact4ever
0
153
Member Avatar for paurik

Try hwinfo, kudzu, lspci, lsusb, dmidecode, etc. You can also find this information in the /proc filesystem in plain-text format (for instance /proc/meminfo). Hope that helps :) , Mike

Member Avatar for eggi
0
182
Member Avatar for 82raju

Hey There, For vmstat's freemem, you're getting the result in kb, but "sar -r" shows you pages, so you need to do the amount x pagesize (in k), which you can get from the "pagesize" command (although it doesn't display in k so you have calculate 8192 = 8k or …

Member Avatar for eggi
0
148
Member Avatar for Rastafari

Hey There, I found this out on the web if you really want to use rtdsc to measure clock cycles, but you can also just use the time function: [CODE]time()[/CODE] and subtract the begin time from the end time for an accurate measurement without getting into too much nitty-gritty [CODE]extern …

Member Avatar for eggi
0
148
Member Avatar for hschitte

Hey There, I don't know if I can advertise in these messages, but check out my signature, go there and do a search on "hwinfo" for a script and some alternatives. Of course, you can just try "hwinfo" also. Depending on what you have privilege to do, you might be …

Member Avatar for eggi
0
112
Member Avatar for ahjiefreak

Hey there, This was bugging me all last night, and I finally figured out what my problem was ;) This should do the trick for you: [CODE]awk 'BEGIN {var=3; highest=0}{ j = $NF;if ( j < var && j > highest ) { highest=j} } END {print highest}' YourInputFile[/CODE] That …

Member Avatar for eggi
0
896
Member Avatar for mooglor

Hey There, The issue may be resolved by just using double quotes around your statement to expand variables from the shell within awk, like: [CODE]awk "{print "zip -m " $ARCHIVE_PATH $FolderToSearch "zip2arc.zip" $CURRENT_DATE " " $1;}"[/CODE] If you want to specifically set a variable within the awk statement, you can …

Member Avatar for ghostdog74
0
136
Member Avatar for Raghavansat

Hey There, It depends on how /usr/sbin/alernatives takes input, but two possible solutions would be echo input|/usr/sbin/alternatives...etc or /usr/sbin/alternatives arg arg <input Basically, you'll have to redirect output to be the commands input. If this is a custom script you might need to add functionality to it so that it …

Member Avatar for eggi
0
94
Member Avatar for Raghavansat

Hmmm, That should actually work. The backticks should return the output of the command rather than just repeat what's between them. It seems as if the backticks are forward ticks. Try copying and pasting this, just in case it's a small mis-type like that. Otherwise, you're not doing anything wrong …

Member Avatar for eggi
0
113
Member Avatar for tomok

Hey There, [CODE]top >outfile[/CODE] captures everything for me running on [TEX]OpenBSD grex.cyberspace.org 4.1 GENERIC#0 i386[/TEX] Do you get any spillover when you do the command? Perhaps adding output redirection would help on your terminal or OS: [CODE]top >out.txt 2>&1[/CODE] Hope some of that helped :) , Mike

Member Avatar for masijade
0
90
Member Avatar for maciac

I would agree to a little bit of both [CODE]if [ "$CHECKA" == "CHECKB" ]; then[/CODE] I'm not sure if the Mac OS underlying *nix requires you to use the $ prefix to expand your variables values. Best of luck :) , Mike

Member Avatar for eggi
0
104
Member Avatar for ahjiefreak

Hey There, If you have the .txt files, just process the data (unless it's already set up this way, in which case you're halfway done) so that the columns are delimited by a pipe or tab (the two delimiters Excel will process automatically). Then just redirect that output into a …

Member Avatar for eggi
0
276
Member Avatar for skelly16

Hey There, Do you have any error output you can post or does it just die quietly? Also, if you're running this in cron, the problem might be with it finding one of the commands in your cat to mail pipe - perhaps fully qualifying uuencode like you've fully qualified …

Member Avatar for eggi
0
781
Member Avatar for ahjiefreak

Hey There, All credit to the guy who wrote this function to convert decimal to binary (included in the snippet below), but you could use awk to do this and apply this function to the 2nd and 3rd fields in each line/record ($2 $3) Hope this helps - let me …

Member Avatar for eggi
0
153
Member Avatar for seemit

Hey there, Just FYI - it's good to put what you've tried in your post, so everyone doesn't think you're doing homework ;) You can write this all on one line if you want - use expr to count the chars on each line of the file [CODE]#!/bin/sh while read …

Member Avatar for seemit
0
95
Member Avatar for larryperl

Hey There, What have you got so far? You should be able to grep the uid/pwd line out of the second file and use awk or sed to insert the necessary line (perhaps use awk to do it all - for the millions of people who are better at using …

Member Avatar for larryperl
0
89
Member Avatar for cnet1989

Hey There, This should get you files that are readable, writable or executable by the user/owner and will keep you from missing directories and such with the grep command: [CODE]find /your/base/dir -perm -u+r,u+w,u+x[/CODE] This way if any combination, or all, of the permissions are set for the user/owner your match …

Member Avatar for dilkash2007
0
63
Member Avatar for tomok

Hey There, The above solution is good for 2 lines. It can be modified for an indefinite number, also, but that doesn't come to my mind right this second ;) If the \n you want to remove is always at the exact end of the line and you have a …

Member Avatar for eggi
0
121
Member Avatar for bungley007

Hey There, This might help, in bash: [CODE]setenv DISPLAY $(who|grep $1 | awk '{print $6}' |sed 's/(//g' | sed 's/)/:0.0/g')[/CODE] in sh or a shell that doesn't support the $() builtin, you could do: [CODE]setenv DISPLAY `who|grep $1 | awk '{print $6}' |sed 's/(//g' | sed 's/)/:0.0/g'`[/CODE] Just add that …

Member Avatar for eggi
0
87
Member Avatar for php.mca

Hey there, Do you just want to take your work and put it in a pdf? You'd just need the Adobe Acrobat software. I'm not sure how to create a pdf in a shell script, if that's what you mean. Best wishes, Mike

Member Avatar for TheOgre
0
1K
Member Avatar for virendra maloo

Hey THere, It sounds like the command itself is exiting the script's subshell. Try running each command bckgrounded in a subshell, like this: [CODE](StoreXML -project xnat -l work/sample1.xml -u admin -p admin -allowDataDeletion true &)[/CODE] or, if you don't want the process to completely detach from the controlling terminal, just …

Member Avatar for eggi
0
71
Member Avatar for cdfd1982

Hey There, Not sure what you're looking for based on the output and then the results. Are these colons and dots in the text? And, the case of P4S, what context are you using to count from E to A? If you could clarify, that would be great. I'm not …

Member Avatar for rikxik
0
141
Member Avatar for learnbash

Hey, There's probably a better way, but off of the top of my head, you could cat file3 and run it in a while loop and just do string comparisons with an " while read line do if [ "${array3[$i]}"" = "$line ] then do what you want fi<${array2[@]} It …

Member Avatar for eggi
0
138
Member Avatar for cyberdyne

It's very simple to do, a billion different ways, but not ethical. You can probably figure it out in a short while if you just practice on your own system for a bit ;) Seriously - I don't think anyone's going to help you with this. It's a forum for …

Member Avatar for chris5126
0
128
Member Avatar for Imti

Hey there, Sounds like you just want to write an interactive looping shell script that would overlay a full feature shell. Check out the bash scripting tutorial - I think it's a sticky post at the top of this section - and you should find how to do everything you …

Member Avatar for eggi
0
83
Member Avatar for Ole Raptor

Hey there, useradd is probably just not in your path. To safeguard against that error in your script, use a fully qualified path, like: /usr/bin/useradd - or /usr/sbin/useradd (It's one of those two on Fedora, I believe) You can check what user already exist on the system by just using …

Member Avatar for Ole Raptor
0
113
Member Avatar for sbecker

Hey There, You just need to double quote your awk statement so it processes $2 from the command line instead of internally - like this awk "{print \$2}" and you should be good :) Only question is do you want the second column from init's ps output? If so, you …

Member Avatar for eggi
0
79
Member Avatar for Imti

Do you want to develop a shell, or a shell script? Either way, post what you have. Unless you're coding a shell. I think you'd have to go to the C++ forum for that and your attachment might be too large If you post some specifics on a shell script …

Member Avatar for eggi
0
52
Member Avatar for Jojo_DC

Hey There, You can use a simple counter and increment it on each loop, clipping it when the value reaches the cutoff point you've assigned. Can you post what you have so far? Hopefully then folks on this board can get you the help you're looking for :) Best wishes, …

Member Avatar for eggi
0
85
Member Avatar for meak99

Hey There, Rather than mix it up with awk, since that's doing what you want, you could sneak a sed command in between your initial command and the awk: e.g. [CODE]ls -l *.dat $*| awk `[/CODE] to [CODE]ls -l *.dat $*| sed 's/\.dat//'|awk `[/CODE] I'm sure it's not the most …

Member Avatar for eggi
0
137
Member Avatar for larryperl

Hey There, You're checking whether or not the -l OPT is being passed in the option argument, so if the -l flag isn't passed to the program, it won't know to even check if there's an error. I would recommend setting the lFlag variable to whatever the "off" value is, …

Member Avatar for eggi
0
103
Member Avatar for chris5126

Hey There, For sar -r, the freemem is the number of pages available the freeswap is number of disk blocks available for swapping (although the blocksize can vary depending on your setup) Basically, yes, you should be able to convert your freemem from sar -r by multiplication against the size …

Member Avatar for eggi
0
159
Member Avatar for Prince89

Agreed, If you have something, post it and we can help you make it work better. For a general "is it up at all", just us ps and grep, much like above: $isitup=`ps -ef|grep "[a]bc"` and test that string to determine if your process is running at all. Best wishes, …

Member Avatar for chunchuwar
0
114
Member Avatar for John Jack

Hey There, You should be able to do this just by using "find"'s -mtime option [CODE]find /directory/ -mtime +7 -exec rm {} \;[/CODE] That will check all the files in /directory/ Hope that helps :) , Mike

Member Avatar for eggi
0
67
Member Avatar for htamayo

Hey There, I think might actually be this line: [CODE]all_bgs=`echo \ `expr $RANDOM % $cnt\``[/CODE] since the first backtick inside your backtick has a space between the escape and backtick. It think it should be this [CODE]all_bgs=`echo \`expr $RANDOM % $cnt\``[/CODE] Sometimes I find it easier to mix different ways …

Member Avatar for eggi
0
105
Member Avatar for alex05

Hey There It depends where you put it. If it's in a script and isn't on the #!/bin/whatever shebang line, then it denotes a comment (perl, all shells). If you mean $# - it resolves to the number of arguments you've passed to your script. Hope that helps :) Mike

Member Avatar for msr_viz
0
248
Member Avatar for larryperl

Hey There, Unless I'm misunderstanding, you just need to move the files and touch them once they're moved? If so, in the loop: [CODE]mv $dir/* $BackupLocation/* find $BackupLocation -exec touch {} \;[/CODE] Hope that helps. If I'm way off base, please let me know :) Thanks, , Mike

Member Avatar for eggi
0
107
Member Avatar for Robbieg6

Hey There, Try using a string operator in your test statement, like -z or -s. The problem you're having may also be related to the eq you use in your test statement. Try changing that to == and you should get different results. Hope that helps :) , Mike

Member Avatar for eggi
0
105
Member Avatar for Shibani

Probably :) You can get around that by running the commands backgrounded in a subshell, like: (./yourscript &) and the shell scripts should continue to run after you log off. You can verify this through ps. Do a ps -ef|grep yourscript and check the PPID for the process. If you've …

Member Avatar for Shibani
0
70
Member Avatar for MONITORING

Hey There, If you want to use $pwd more than once, you should change the original pwd= assignment to a different variable name since you reference the original value in the value of the variable of the same name later. Otherwise, you could also just do: pwd="${pwd}${mkdir}\" just a matter …

Member Avatar for MONITORING
0
101
Member Avatar for papers63

Hey There, it looks like these two variables never get set: $listdir $sname You'll need to assign those variables values. Since it's dynamic, it depends on how you want to do it, but maybe: listdir=$1 nsname=$2 Not really sure what you're shooting for. You could seed $listdir with `ls`, but …

Member Avatar for eggi
0
84
Member Avatar for wiz83

chmod the script 755, and if you want to run it as perl scriptname in crontab, just be sure to give the absolute path to perl in your entry, like: /usr/bin/perl scriptname and it should work either way Hope that helps :) , Mike

Member Avatar for DimaYasny
0
198
Member Avatar for rhnaeco

This is true of sed, also. Perhaps something as simple as var=`head -1 tex 2>&1|awk '{print $1}'` woud do it ? , Best wishes, Mike

Member Avatar for ghostdog74
0
141
Member Avatar for syaorankun

Hey There, You should be able to match a literal asterisk in sed with [CODE]echo $1 | sed 's/\*//'[/CODE] or [CODE]echo $1 | sed 's/\*//g'[/CODE] to get all the asterisks in the variable if there are more than one. Please let me know if I'm misunderstanding your question. You may …

Member Avatar for masijade
0
372
Member Avatar for RohitSahni

Hey there did you try tr and specify only alpha characters? [CODE]tr '[:upper:]' '[:lower:]'[/CODE] Hope that helps :) , Mike

Member Avatar for masijade
0
152
Member Avatar for rajarp

I agree - aside from realpath and other provided solutions in C and perl, I think you can't do it very easily. Perhaps (but this would still be restrictive) [CODE]find ../../MIS/LANDING -name MIS_Customer_\*|sed 's/\.\.\/\.\.\//\/home\/md\/DEV\//'[/CODE] since it requires forknowledge of the directory your absolute path goes to. I'd be interested in …

Member Avatar for masijade
0
90
Member Avatar for binnie

Hey There, For loop example: [CODE]for x in a b c do echo $x done[/CODE] conditional example [CODE]if [ $a -lt 0 ] then echo $a elif [ $a -gt 5 ] echo $a else echo $a fi[/CODE] You can use printf in bash to work with floating point numerals, …

Member Avatar for binnie
0
133
Member Avatar for spikywits

Hey there You can use patch to do that, with diff: [CODE]diff fileb filea >DIFF patch -p0 -i DIFF fileb[/CODE] You can also do it this way - less hassle and less confusing sometimes: [CODE]cat filea fileb|sort -u[/CODE] There are probably more and better ways to do it depending on …

Member Avatar for radoulov
0
113

The End.