Sponsored Content
Top Forums UNIX for Dummies Questions & Answers I am not able to use variables in system command in a C program Post 302760483 by RudiC on Thursday 24th of January 2013 05:43:04 AM
Old 01-24-2013
You should allocate a char variable, fill it with the string constant "whereis " (e.g. sprintf) and the contents of your user input variable (e.g. strcpy), and supply that to the system call.
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Dump program variables

Hi, Wish if could provide some clues. How do I dump all the C program variables(global) into say a file with their names and the values. So that when I restart the application again I could use this same file for reinitializing.Is this possible? Thanks, Reji (1 Reply)
Discussion started by: rejise
1 Replies

2. UNIX for Dummies Questions & Answers

Dummie: How do I get variables mid program

I'm writing a simple program in unix and was wondering how mid switch I can run a program and get someone to enter variables for it i.e.: #!/bin/csh -f echo "If you wish to do v press v" echo "If you wish to compile press c" echo "If you wish to add an entry press a" echo "If you wish to... (1 Reply)
Discussion started by: RichardB
1 Replies

3. Shell Programming and Scripting

Passing shell variables to awk program..

Hello, Can we pass shell variables like $PATH etc. to a awk program part for example, awk ' { fieldValue=$PATH .... }' file (1 Reply)
Discussion started by: Vishnu
1 Replies

4. Programming

using system cp command in C program

Hi i used the following code to copy a directory from a source location to dest. argv contains the source loc i/p by the user. strcpy(source,argv); strcpy(dest,"/home/MainServer/Job_dir/"); system("cp -r $source $dest"); it complies properly but during execution of the program it... (2 Replies)
Discussion started by: mridula
2 Replies

5. Shell Programming and Scripting

How to access the C program variables in shell script

hi I wanted to access the C program variables in shell script. This script is called from the same C program. What are the ways in which i can access variables thankx (3 Replies)
Discussion started by: bhakti
3 Replies

6. Shell Programming and Scripting

problem accessing Multiple Variables from C Program to a Shell script

program name--test #!/bin/bash output1=`/home/user/a.c` output2=`/home/user/a.c` k=`$output1 + 1` m=`$output2 + 1` echo $k echo $m --------------------------------------------------------------------------- prgram name--a.c #include<stdio.h> int main() (1 Reply)
Discussion started by: sameworld1980
1 Replies

7. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

8. UNIX for Dummies Questions & Answers

Small Program with variables

Hello Geniuses of the unix world. please help, stupid chemist. I have the following script that I need to create a file. Doesnt make sense unless i explain this way: I need to create a file called summary.in I would like all these lines to be inserted however in the command line I would like the... (1 Reply)
Discussion started by: gingburg
1 Replies

9. UNIX Desktop Questions & Answers

Knowing the size and location of variables in a C program

So I need some help with this. Pardon me if I'm posting in the wrong forum, after some googling for my answer and finding nothing I found this forum. It seemed appropriate for what I was seeking. I just didnt find a forum that concerned the use of GDB. I'm learning to use the C language and GDB.... (2 Replies)
Discussion started by: Cambria
2 Replies

10. Shell Programming and Scripting

Using env variables to run a program

Hi there, I need urgent help with a small program that is run via shell script. Unfortunately I only understand the bare basics of shell scripting and can't figure out how to do this. We have a program that tests the connection between 3 servers. I have a script that lets the program run on... (15 Replies)
Discussion started by: Pherdinand
15 Replies
on(1)							      General Commands Manual							     on(1)

NAME
on - execute command on remote host with environment similar to local SYNOPSIS
| host [command [argument] ... ] DESCRIPTION
executes a command on a remote host, using an environment similar to that of the invoking user where: host specifies the name of the host on which to execute the command. command specifies the command to execute on host If command is not specified, starts a shell on host. argument ... is a list of arguments for command. The user's environment variables are copied to the remote host, and the file system containing the user's current working directory is NFS mounted on the remote host (see nfs(7)). The command is executed on the remote host in the user's current working directory. Commands using relative path names that reference file system objects within the user's current working file system have the same behavior as running the command on the client. The behavior of commands using relative path names that cross the file system boundary or commands using absolute path names depends on the organization of the remote host's file system. Implicit and explicit use of environment variables may also cause a command's behavior to be dependent on the organization of the remote host's file system. For example, the environment variable usually contains absolute path names. Standard input, output and error of the remote command are connected to the appropriate file descriptors on the client. The remote execution daemon does not allow to execute a remote command. The signals and are propagated to the remote command. and are ignored by the remote command. All other signals are delivered to the com- mand. In order to execute a remote command, the remote host must be configured to execute (see rexd(1M)). Options recognizes the following options: Interactive mode. This option is required for commands that must communicate with a terminal such as or Terminal mode changes are propagated to the server. The standard input for an interactive command must be a tty device. The and options are mutually exclusive. Debug mode. Print diagnostic messages during startup of the command. These messages are useful for detecting configuration problems if the command to a specific host is failing. No input mode. This option causes the remote command to get end-of-file (EOF) when it reads from standard input, instead of connecting the standard input of the command to the standard input of the remote command. The option is required when running commands in the background. The and options are mutually exclusive. DIAGNOSTICS
The host name host was not found in the hosts database. The host host is down, unreachable on the network, or not running A problem occurred trying to find the user's current working directory (current_dir). A problem occurred trying to determine the mount point of the user's current working directory (current_dir). The standard input (stdin) of the command with the option is not a tty device. Errors that occur on the server server are propagated back to the client. These messages are documented in the DIAGNOSTICS section of rexd(1M). AUTHOR
was developed by Sun Microsystems, Inc. SEE ALSO
exports(4), rexd(1M). on(1)
All times are GMT -4. The time now is 04:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy