152 Posted Topics
Re: This is allowable C, but can cause you problems if you are not super careful - meaning: it will cause problems. But it does answer your question. [code] #include <string.h> int myfunc(const char *a, const char *b, const int i) { ............. stuff return 1; } void foo(char *a, char … | |
Re: What normally is done (assuming that only one of the code pieces has a main() ) is to compile each of the sourcefiles into a separate object file and then link them all into one program. To simplify a compile you can create a makefile to do this, or create … | |
Re: find does date comparisons for you. Example - this code deletes files older than 48 hours (2 days): [code] find /home/julie/trash -type f -mtime +2 -exec rm -f {} \; [/code] | |
Re: [code] myvar="Hi there" backwards=`echo "$myvar" | rev` echo "$backwards" [/code] | |
Re: This isn't as straightforward as you might think. Those perl regexes that look like this [code] (A)|(B)|(C)[/code] for your "A","B","C" test search will work pretty much. What OS are you on? Do you have a regex library installed? which one?(if you can tell)... | |
Re: One way [code] grep '^TDR ' Inputfile.log [/code] | |
Re: awk is what you want. Assume your extract code runs like this: extract and it prints data to stdout. And assume you have columns of data and you want column #3 to be larger than 10. [code] extract | awk ' if($3 > 10) {print $0} ' > resultfile [/code] … | |
Re: [code] echo 'ftp://user:pass@host/path' | sed 's#[|:;>@/]# #g' | read dummy usr pwd hst pth # or echo 'ftp://user:pass@host/path' | tr -s '/' ' ' | tr -s ':' ' ' | tr -s '@' ' ' | read dummy usr pwd hst pth echo $pth echo $pwd echo $hst echo … | |
Re: Wow. [code] void main() - don't use void main. main() returns an int. { clrscr(); while(i--!=6) - where is i set to some intitial value? i=i+2; - this is the end of the while loop I think you are missing {} to make a while block? printf("%d\n",i); getch(); } [/code] … | |
Re: [code] while read text do echo "$text" | sed 's#[|:;>]# #g' | read nm1 nm2 nm3 nm4 echo "$nm1 $nm2 $nm3 $nm4" done < inputfile [/code] | |
Re: Andor and AD are correct. What exactly are you trying to do? If you can give us an exact requirment, we can tell you what to do. | |
Re: Another option: grep. You have to show effort before we do your homework for you. There is also a sed one hunk of code that does it as well. You can also use a while ... do .. done loop. | |
Re: Since this is in Shell scripting: [code] pid=$$ [/code] $$ returns the pid of the current process (the one the shell is running in) | |
Re: HPUX supports alloca() - it has advantages and disadvantages [code] good - it automatically frees all objects created by alloca calls when the function making those calls exits good - it is about 100X faster than malloc bad - it allocates from stack, not heap. stack space size limits are … | |
Re: This is actually an Oracle question: dba_profiles sets the rules for the system, not how many login failures there are for a given user. Offhand I do not know what SYS table Oracle currently uses to store this information. Plus, this approach is an idea that is doomed to failure … | |
Re: I'd use arrays: [code] #!/bin/ksh optfile=filename set -A opts $(awk 'BEGIN {FS="="} { if($0~ / page_size/) { print $2}}' $optfile) for i in 0 1 2 do echo ${opts[i]} done [/code] If you're using bash just "declare" opts as an array. | |
Re: awk works for this pretty well - [code] awk '{ print $0 if($0=="Line2") {print "INSERTLINE2"} if($0=="Line3") {print "INSERTLINE3"} }' file > newfile [/code] | |
Re: This checks $2 to see if ".kext" is anywhere in the $2 parameter [code] echo "$2" | grep -q '.kext' if [[ $? -eq 0 ]] ; then echo '.kext found' else echo '.kext not found' fi [/code] | |
Re: [code] cd /to/my/directory find . -name '*.jpg' | \ while read file do mv $file "new"$file done[/code] PS: mv works only within a filesystem. Even though you may be in directories that are close in terms of directory trees does not mean there are no intervening mountpoints. - | |
Re: [code] #!/bin/ksh find /path/to/files -name 'tmp_*' | \ while read filename do tmpfile=${filename#tmp_} mv "$filename" "emkt""$tmpfile" done [/code] | |
Re: try an alias: [code] alias home="cd /home/budroeducom" alias cd1="cd /some/longpath/to/somewhere" [/code] typing [code] home [/code] will execute [code]cd /home/budroeducom[/code] To see what alias commands are already there: [code]alias[/code] will list them for you. | |
Re: First off, hints can be overridden by the Oracle optimizer. Just so you know. If you want to track performance do this: 1. Before you run your SQL ALTER SESSION SET SQL_TRACE TRUE; run your sql ALTER SESSION SET SQL_TRACE FALSE; 2. Now find where the trace file is: select … | |
Re: This is more complex than you might think. Here is an in-depth article on sending email: [url]http://asktom.oracle.com/pls/ask/f?p=4950:8:6225936216616544881::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:255615160805[/url] | |
Re: /etc/profile for "world" wide variables. The basic PATH and sometimes TMOUT is usually set here. .bashrc or .profile for a given user or yourself. Edit the file and add something like: [code] export MYVAR="SOME VALUE" [/code] Save the file, then source it [code] source .bashrc # or source .profile [/code] … | |
Re: You are not calling strtok correctly. try something like this: void foo(char *string1, char *string2) { char *first=strtok(string1,"|"); char *second=string2(string2,"|"); while(first!=NULL) { printf("%s\n",first); first=strtok(NULL,"|"); } while(second!=NULL) { printf("%s\n",second); second=strtok(NULL,"|"); } } | |
Re: Your logic doesn't make any sense to me... You want to get to the "got it" statement - this does it. [code] #!bin/ksh a=5 while [[ $a -gt 5 ]] do echo "a=5 and not went to else cdn." if [[ $a==5 ]] then echo "a=6" fi echo "a=5 and … | |
Re: It's giving you the ip. putty connects over the network. Are you not connected to the remote box? Plus, who is POSIX.2. If the box on the other end is not POSIX-compliant , or is a version of , say, Solaris or HPUX, from before 1994, then it won't work … | |
Re: [ -d $1 ] on line 59 test is postive when $1 [b]is [/b] a directory. Your logic is reversed - you display "is in the current directory" when this test is true, when the file is a directory. | |
Re: Not to inject extra complexity, but if you need to get those exterior circles to fit together into a nice ring, with each smaller circle touching it's neighbor and the circumference of the big one, then it's math time. See the Soddy circle page on Mathworld: [url]http://mathworld.wolfram.com/SoddyCircles.html[/url] Look for Bllew's … | |
Re: Here is why it happened: C programs live in memory as segments. The segments have names like TEXT and BSS. Anyway, const values get placed in read-only memory, one of the segments. The read/write DATA segment is always created, and it looks like your compiler bent over backwards to allow … | |
Re: Here is a tutorial, follow the link for deinterlacing [url]http://www.100fps.com/[/url] Most video processing software can do it. | |
Re: You need to use coprocesses to have a read timeout. At least that is the only way I know to do it in ksh. bash read has a timeout two separate scripts: main.sh & asynch_signal.sh asynch_signal.sh [code] #!/bin/ksh # file: asynch_signal.shl send a signal to parent process after $1 seconds … | |
Re: See [url]http://www.unix.com/showthread.php?t=29108[/url] for an answer | |
Re: You will have to try to download the separate file, which ought to be protected, but looks like it is not. It's the same ideas as downloading a script like this: [code] grep 'stuff' myfile [/code] The download does not get the grep executable. Same idea. | |
Re: First off: -y produces side by side output. diff tries to fit two lines into 80 columns, that's why the lines are truncated. -r displays a filename. otherwise you would never know what the diff output was based on. what are you trying to do? && what output would you … | |
Re: There isn't "a" version of UNIX. pty is suggesting the BSD version of UNIX manifested as Linux. Good choice. There are other families of UNIX out there. POSIX was created to try to make "one" UNIX specifications so it was easier to work and port across platforms. | |
Re: It sounds like you have to set bits to toggle pixels on the display? Or does the display have an embedded driver to respond to ANSI tty commands? | |
Re: [code] tr -s '[:lower:]' '[:upper:]' < filename > newfilename [/code] You have to use POSIX character classes, not "regex" classes. this: < filename > filename : causes filename to be truncated to zero length BEFORE tr runs. | |
Re: For starters we need to know what flavor(s) of unix are involved. And, to keep to you busy, you'll need to be sure to have set up authentication keys between the main host and the remotes so that ssh will work in a script..... they may well be set up … | |
Re: Favorites is a shell folder, meaning what it's name and location are depend on explorer.exe It's not a regular file, so you have to call the SH api. Here is an example that gets the path to favorites: [code] #include <windows.h> char *favorites_path(char *destination_path) { ITEMIDLIST IDL; int rc; *destination_path=0x0; … | |
Re: I think he means what will print the username [code] /* windows: */ #include <windows.h> void MyNameIs(void) { char username[24]={0x0}; GetUserName(username,sizeof(username)); printf("%s\n", username); } /* unix */ #include <unistd.h> void MyNameIs(void) { char *username=getlogin(); printf("%s\n", username); } [/code] | |
Re: or try [code] . myscript.sh #or source .myscript.sh [/code] | |
Re: Some exit codes are expected under certain circumstances in decent shell code and should be used for those conditions: [url]http://www.tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF[/url] Another point of view is to standardize your exit codes using the values taken from the C header file sysexits.h [url]http://cvs.opensolaris.org/source/xref/on/usr/src/head/sysexits.h[/url] | |
Re: Ten lines of shell script is easier to maintain than 70 lines of perl. It's also faster to develop. Experienced sysadmins use shell scripts, then use perl/ruby/python when they cannot do whatever it is in shell coveniently or very well. In practice what usually happens is that new sysadmins learn … | |
Re: [quote] accept() call fills in this structure with the address of the connecting entity, as known to the underlying protocol. In the case of AF_UNIX sockets, the peer's address is filled in only if the peer had done an explicit bind() before doing a connect(). Therefore, for AF_UNIX sockets, in … | |
| |
Re: The sleep command in unix is guaranteed to sleep a minimum. Due to the way quanta (time slices) work in OS schedulers, other processes may get the cpu ahead of the sleeper who just awoke. ie., there is no guarantee of an upper limit. sleep 1 may last longer than … | |
Re: [code] char str[10]={0x0}; char *p=str; strcpy(str,"string"); *(p+2)='a'; [/code] You have to allocate storage in memory for data - first. Then place data in the storage next - if you want to be able to modify the data. | |
Re: I don't have a quick good answer, getopts only returns the first string of multiple arguments into OPTARG for a given option Here is a good discussion of argument handling: [url]http://www.shelldorado.com/goodcoding/cmdargs.html[/url] | |
Re: cksum is a fast way to see if two files are the same. However, ftp-ing folders of files over just to compare files is a waste of bandwidth and time. What exactly are you trying to do - not how, but what do you need to acheive? |
The End.