12-12-2001
Quote:
Here is my problem. I don't know make this redirection thing work. The output file (called output.c) looks like this
#include
int main()
{
int k;
int m;
print f("%d\n", k);
printf("%d\n", m);
return 0;
}
The reason that you are getting a bunch of numbers is that the int vars k and m are never assigned a value. You are displaying the values of what is in the memory address of k and in the memory address of m at the time of execution. The contents of an unassigned variable at execution time is commonly referred to as "compilter garbage".
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
The code below works, it's a part of a bash shell script that serve to search a pattern $pattern_da_cercare in the files contained in a directory $directory_iniziale.
Now the proble is:
How can I redirect stderr to a file?
PS: so I want to redirect ALL the errors to a file.
I tryed... (9 Replies)
Discussion started by: DNAx86
9 Replies
2. Shell Programming and Scripting
hi all,
how to redirect the stdout msg in command line and file at the same time?
e.g
i got the script named test.sh, content as following:
#!/bin/sh
echo "111"
when i run the script ./test.sh > log.log, it will wirte the "111" into log.log, but how to show the "111" in command line... (2 Replies)
Discussion started by: eric_wong_ch
2 Replies
3. Shell Programming and Scripting
Hi,
I have a Perl script that finds some files based on some criteria and then it processes the file contents using some logic.
Extract:
print "Started ... ";
my $command = "<unix command>";
@arr=`$command`;
$size=@arr;
print "Size: ".$size
If I turn on the Perl debugging option then I... (3 Replies)
Discussion started by: King Nothing
3 Replies
4. UNIX for Dummies Questions & Answers
Hi Guys,
I m new to UNIX and new to this forum. Was wondering if someone can help me understand redirection (standard input output pipeline etc)
for starters, not too sure what this would mean
who | sort > sortedfile | pr | lp
im starting to understand common commands but when throwing... (2 Replies)
Discussion started by: jmack123
2 Replies
5. Shell Programming and Scripting
Hello everyone,I'm reading a book and there's code fragment:
exec 3>&1
ls -l 2>&1 >&3 3>&- | grep bad 3>&-
exec 3>&-
It says that the red part of that code does not close fd 3 but the green does close the fd 3.I can't understand that.....Why?Any predicate will be appreciated.:) (18 Replies)
Discussion started by: homeboy
18 Replies
6. Web Development
Hello
I have a domain where i need a redirection as described below :
i.e
mydomain.com/t-ABC-048796/sample.jpg
must redirect to
mydomain.com/jjj/top/8796/sample.jpg
As you can see from the source URL (mydomain.com/t-ABC-048796/sample.jpg) i need the last four characters... (2 Replies)
Discussion started by: unimaxlin
2 Replies
7. Shell Programming and Scripting
I want to redirect stderr and have the following peice of code
$ cat t1.ksh
#!/bin/ksh
func2()
{
diff /tmp/jdlkwjdlkejew /tmp/djlkwejdlewdjew >$OUTPUT_FILE 2>>$ERR_FILE
}
func1()
{
let counter=0
while
do
print -u2 "Error: In main function"
func2
let... (1 Reply)
Discussion started by: BeefStu
1 Replies
8. Shell Programming and Scripting
Hello All,
I am using the below script to gather various tools running by the user, we have more than 100 tools running on the server so my challenge is to redirect memory & cpu load to the file with the name of the tool.so am using the below script i am stucking how to redirect to the file... (2 Replies)
Discussion started by: ajaincv
2 Replies
9. Solaris
Hi
I am using solaris 10. When running a grep command with multiple files the output is the same as the order of the input. As soon as I pipe the output to another command then it seems that standard error takes precedence, over standard output and gets sent to the pipe first.
ie grep -c... (7 Replies)
Discussion started by: chronics
7 Replies
10. UNIX for Dummies Questions & Answers
explain the redirections 1>, 2>, 3>, .....
and 1< ,2<,3<.....
where we use these things
thanks
Thread moved from AIX forum (2 Replies)
Discussion started by: tsurendra
2 Replies
LEARN ABOUT OSF1
memalloc_attr
memalloc_attr(3) Library Functions Manual memalloc_attr(3)
NAME
memalloc_attr - Query the memory allocation policy and attributes (libnuma library)
SYNOPSIS
#include <numa.h>
int memalloc_attr(
vm_offset_t va, memalloc_attr_t *attr );
PARAMETERS
The user virtual address for which the memory allocation policy is requested. Points to a buffer to receive the memory allocation policy
and attributes for the page containing the specified virtual address.
DESCRIPTION
The memalloc_attr() function returns the current memory allocation policy and associated attributes in the buffer pointed to by attr for
the address specified by va.
If radset information about the memory allocation policy is desired, a radset must be allocated through the radsetcreate() function, and
the mattr_radset element of the attr argument must point to that radset. Otherwise, a 0 must be specified for the mattr_radset.
EXAMPLE
#include <numa.h> main() {
vm_offset_t va;
memalloc_attr_t attr;
int id;
int flags = SET_CURSOR_CONSUME;
rad_cursor_t cursor = SET_CURSOR_INIT;
radsetcreate(&attr.mattr_radset);
va = (vm_offset_t)&attr;
/* no policy in effect - return zeroes */
if (memalloc_attr(va, &attr) == -1) {
perror("memalloc_attr");
radsetdestroy(&attr.mattr_radset); return 0;
}
printf("mattr_policy = 0x%lx
", attr.mattr_policy);
printf("mattr_rad = 0x%lx
", attr.mattr_rad);
printf("mattr_stride = 0x%lx
", attr.mattr_stride);
printf("mattr_distance = 0x%lx
", attr.mattr_distance);
printf("mattr_pagesz = 0x%lx
", attr.mattr_pagesz);
/* set policy */
attr.mattr_policy = MPOL_DIRECTED;
attr.mattr_rad = 0;
if (nmadvise((void *)va, sizeof(memalloc_attr_t), 0, &attr) == -1) {
perror("nmadvise");
radsetdestroy(&attr.mattr_radset); return 0;
}
if (memalloc_attr(va, &attr) == -1) {
perror("memalloc_attr");
radsetdestroy(&attr.mattr_radset);
return 0;
}
printf("mattr_policy = 0x%lx
", attr.mattr_policy);
printf("mattr_rad = 0x%lx
", attr.mattr_rad);
printf("mattr_stride = 0x%lx
", attr.mattr_stride);
printf("mattr_distance = 0x%lx
", attr.mattr_distance);
printf("mattr_pagesz = 0x%lx
", attr.mattr_pagesz);
/* enumerate the mattr_radset */
printf("
Enumerating radset members:
");
while ((id = rad_foreach(attr.mattr_radset, flags, &cursor)) != RAD_NONE) {
if ((id % 8) == 0)
printf("
");
printf("%3d, ", id);
}
printf("
"); }
RETURN VALUES
Success. In this case, the function stores the requested memory allocation policy and attributes in the buffer pointed to by attr. If no
memory allocation policy has been set for the specified virtual address (e.g., madvise() or nmadvise()) not called for that address), a
zeroed attr structure is returned. Failure. In this case, the function sets errno to indicate the error.
ERRORS
If the memalloc_attr() function fails, it sets errno to one of the following values: The address pointed to by va, attr, or mattr_radset is
invalid. The mattr_radset element of the attr argument points to an invalid RAD set, possibly one that has not been created by a rad-
setcreate() call.
SEE ALSO
Functions: numa_intro(3)
Files: numa_types(4)
memalloc_attr(3)