GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- C code and stdin
Operating System - HP-UX
1843366
Members
3777
Online
110215
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2004 03:57 PM
10-22-2004 03:57 PM
C code and stdin
i do not know how to get my C code (c_code) to take stdin and pass it as stdin to a UNIX command (unix_cmd) given as an argument ...actually the c_code does many things but below is the part i am having trouble with
also note that there may be an argument/s for the unix_cmd like unix_cmd_arg1 etc...
echo fileA | c_code unix_cmd unix_cmd_arg1
i want the above to behave as if i did the following
echo fileA | unix_cmd unix_cmd_arg1
basically my c_code C program is tweaking certain HP-UX environment settings and is to be used as a "wrapper" for some application binary files that some of my users need to run
i hope i explained this clear enough and understand that i am very rusty on C to the point where i am having problems knowing what i even need to make this work
also note that there may be an argument/s for the unix_cmd like unix_cmd_arg1 etc...
echo fileA | c_code unix_cmd unix_cmd_arg1
i want the above to behave as if i did the following
echo fileA | unix_cmd unix_cmd_arg1
basically my c_code C program is tweaking certain HP-UX environment settings and is to be used as a "wrapper" for some application binary files that some of my users need to run
i hope i explained this clear enough and understand that i am very rusty on C to the point where i am having problems knowing what i even need to make this work
hola
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2004 11:20 PM
10-22-2004 11:20 PM
Re: C code and stdin
Hey Marc,
for i in $(cat fileA)
do
unix_cmd $i
done
or you could take a look at the unix command xargs.
hope it helps!
for i in $(cat fileA)
do
unix_cmd $i
done
or you could take a look at the unix command xargs.
hope it helps!
jaton
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2004 11:46 PM
10-22-2004 11:46 PM
Re: C code and stdin
you would want to do an execvp(3) call for executing the command. i guess stdin/stdout/stderr are inherited by the exec'd process from the parent. so you need something like this:
---
#include
main (int argc, char *argv[])
{
/* your customizations here */
execvp(argv[1], &(argv[1]));
}
---
this seems to work :
----
[ranga@adishesha c]$ cc ./exc.c -o exc
[ranga@adishesha c]$ ls | grep out
a.out
[ranga@adishesha c]$ ls | ./exc grep out
a.out
[ranga@adishesha c]$ echo $?
0
[ranga@adishesha c]$ ls | ./exc grep ranga
[ranga@adishesha c]$ echo $?
1
[ranga@adishesha c]$ ./exc ls ranga 2>error
[ranga@adishesha c]$ cat error
ls: ranga: No such file or directory
----
--
ranga
[i work for hpe]
---
#include
main (int argc, char *argv[])
{
/* your customizations here */
execvp(argv[1], &(argv[1]));
}
---
this seems to work :
----
[ranga@adishesha c]$ cc ./exc.c -o exc
[ranga@adishesha c]$ ls | grep out
a.out
[ranga@adishesha c]$ ls | ./exc grep out
a.out
[ranga@adishesha c]$ echo $?
0
[ranga@adishesha c]$ ls | ./exc grep ranga
[ranga@adishesha c]$ echo $?
1
[ranga@adishesha c]$ ./exc ls ranga 2>error
[ranga@adishesha c]$ cat error
ls: ranga: No such file or directory
----
--
ranga

- Tags:
- execvp
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP