152 Posted Topics

Member Avatar for caltiger

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 …

Member Avatar for caltiger
0
146
Member Avatar for shadowmoon

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 …

Member Avatar for jim mcnamara
0
154
Member Avatar for titotoms

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]

Member Avatar for jim mcnamara
0
108
Member Avatar for stephan.opitz

[code] myvar="Hi there" backwards=`echo "$myvar" | rev` echo "$backwards" [/code]

Member Avatar for jim mcnamara
0
65
Member Avatar for sgriffiths

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)...

Member Avatar for ~s.o.s~
0
99
Member Avatar for Lois33
Member Avatar for code321

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] …

Member Avatar for code321
0
91
Member Avatar for mfeldheim

[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 …

Member Avatar for kamitsin
0
98
Member Avatar for pointers

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] …

Member Avatar for jim mcnamara
0
181
Member Avatar for sgriffiths

[code] while read text do echo "$text" | sed 's#[|:;>]# #g' | read nm1 nm2 nm3 nm4 echo "$nm1 $nm2 $nm3 $nm4" done < inputfile [/code]

Member Avatar for jim mcnamara
0
107
Member Avatar for kararu
Re: Gdb

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.

Member Avatar for jim mcnamara
0
82
Member Avatar for mahul000

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.

Member Avatar for jim mcnamara
0
133
Member Avatar for Deepak Ram

Since this is in Shell scripting: [code] pid=$$ [/code] $$ returns the pid of the current process (the one the shell is running in)

Member Avatar for jim mcnamara
0
95
Member Avatar for bhushanm

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 …

Member Avatar for jim mcnamara
1
168
Member Avatar for liezer

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 …

Member Avatar for sut
0
107
Member Avatar for WolfPack

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.

Member Avatar for jim mcnamara
0
174
Member Avatar for toztech

awk works for this pretty well - [code] awk '{ print $0 if($0=="Line2") {print "INSERTLINE2"} if($0=="Line3") {print "INSERTLINE3"} }' file > newfile [/code]

Member Avatar for sut
0
180
Member Avatar for toztech

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]

Member Avatar for sut
0
106
Member Avatar for Alphabeta

[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. -

Member Avatar for jim mcnamara
0
119
Member Avatar for microbiologist

[code] #!/bin/ksh find /path/to/files -name 'tmp_*' | \ while read filename do tmpfile=${filename#tmp_} mv "$filename" "emkt""$tmpfile" done [/code]

Member Avatar for jim mcnamara
0
322
Member Avatar for budroedotcom

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.

Member Avatar for budroedotcom
0
159
Member Avatar for hari_bk

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 …

Member Avatar for jim mcnamara
0
69
Member Avatar for hari_bk

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]

Member Avatar for jim mcnamara
0
70
Member Avatar for nanosani

/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] …

Member Avatar for John A
0
148
Member Avatar for sgriffiths

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,"|"); } }

Member Avatar for jim mcnamara
0
236
Member Avatar for parani

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 …

Member Avatar for jim mcnamara
0
150
Member Avatar for katharnakh

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 …

Member Avatar for jim mcnamara
0
98
Member Avatar for Shadowchaser

[ -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.

Member Avatar for jim mcnamara
0
131
Member Avatar for ultra vires

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 …

Member Avatar for jim mcnamara
0
329
Member Avatar for ~s.o.s~

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 …

Member Avatar for ~s.o.s~
0
162
Member Avatar for natasha_sr

Here is a tutorial, follow the link for deinterlacing [url]http://www.100fps.com/[/url] Most video processing software can do it.

Member Avatar for jim mcnamara
0
50
Member Avatar for kevin_m

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 …

Member Avatar for jim mcnamara
0
106
Member Avatar for Stud33
Member Avatar for Stud33
0
77
Member Avatar for lconvoy

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.

Member Avatar for jim mcnamara
0
94
Member Avatar for nihao

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 …

Member Avatar for jim mcnamara
0
178
Member Avatar for Tdot

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.

Member Avatar for blud
0
241
Member Avatar for blewis999

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?

Member Avatar for Salem
0
106
Member Avatar for nileshdalvi

[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.

Member Avatar for jim mcnamara
0
61
Member Avatar for rags

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 …

Member Avatar for jim mcnamara
0
422
Member Avatar for huffstat

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; …

Member Avatar for huffstat
0
115
Member Avatar for bigdill

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]

Member Avatar for jim mcnamara
0
69
Member Avatar for alvaro
Member Avatar for girish.sh

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]

Member Avatar for masijade
0
134
Member Avatar for Nisha R

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 …

Member Avatar for chrisranjana
0
249
Member Avatar for winbatch

[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 …

Member Avatar for kris.c
0
167
Member Avatar for Mushy-pea
Member Avatar for vanii

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 …

Member Avatar for jim mcnamara
0
345
Member Avatar for cocojim

[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.

Member Avatar for cocojim
0
237
Member Avatar for swmercenary

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]

Member Avatar for jim mcnamara
0
225
Member Avatar for mcrosby

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?

Member Avatar for mcrosby
0
159

The End.