Sponsored Content
Homework and Emergencies Homework & Coursework Questions Help with Interactive / Non Interactive Shell script Post 302344440 by rits on Sunday 16th of August 2009 04:32:19 PM
Old 08-16-2009
Question Help with Interactive / Non Interactive Shell script

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines.
It then prompts for deletion of the file.
If user supplies arguments with the script , then it works on those files only.
- - - - - - - - - - - -- - - - - - - - - - - - - - -

The main problem Im facing with this question is how to make the program pick up a C program in case no arguments are specified .

Code :
Code:
ls -lrt *.C

Please elaborate it .
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Korn shell interactive script

Hi, How can I prompt a user for two input and pass the input to variables in the script. I have the following script but it is not working: +++++++++Begin+++++++++++ #!/bin/sh database_c=$1 output_f=$2 echo "Your db is $1\nOutput is $2" +++++++++End+++++++++++ Thanks, Leonard (3 Replies)
Discussion started by: leonard905
3 Replies

2. Shell Programming and Scripting

Schedule an interactive shell script

Hi, I need to schedule a shell script which executes another shell script along with a series of other commands. When the inner shell script is executed it prompts for a password..... This inner shell cannot be changed How can I do this???? Regards, Chaitrali. (4 Replies)
Discussion started by: Chaitrali
4 Replies

3. OS X (Apple)

interactive shell script to create users 10.4

Hello everyone, Not sure if this is the right place, but OS X isn't your standard Unix, so I figured here would be best. I am looking at creating a script that will be interactive that admins can run to create users. Now, 10.4 uses netinfo database and netinfo manager to handle it's users. ... (3 Replies)
Discussion started by: tlarkin
3 Replies

4. Shell Programming and Scripting

how to write a shell script to login to a system which is interactive.

Can anybody help me to write a shell script to login interactive system once u open a connection using telnet it will ask for USERCODE: PASSWORD: DOMAIN: (1 Reply)
Discussion started by: sudhakaryadav
1 Replies

5. Shell Programming and Scripting

How to make interactive shell script a automated one?

Hi, I am new to shell scripting.I have written a very simple shell scipt that asks for the username and password on executing. i.e echo "Enter username :" read usrname; echol "Enter password :"; read passwd; echo usrname; echo passwd; but now I want to make it automatic , such... (2 Replies)
Discussion started by: bhaskar_m
2 Replies

6. Homework & Coursework Questions

How to write script that behaves both in interactive and non interactive mode

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (8 Replies)
Discussion started by: rits
8 Replies

7. Shell Programming and Scripting

Use expect to run an interactive shell script?

Hi all, I have a bit of a vexing issue here and I'm not certain how best to go about it. Basically, I want to run a shell script and automate the user prompt of hitting 1 to fully uninstall Symantec Anti-Virus for OS X. Would expect be the best way to do this? (5 Replies)
Discussion started by: prometheon123
5 Replies

8. Shell Programming and Scripting

Shell script using an interactive command

Hello experts, I have a to write script for monitoring, the script would use a command and I plan to write the script as follows while true do command -arg sleep 2 clear done The output would be set up on a screen for monitoring. However the issue is that the command used in... (2 Replies)
Discussion started by: maverick_here
2 Replies

9. UNIX and Linux Applications

How to write automated interactive shell script?

Hello everyone, I just want to write a shell script for automatic feeding the username and password prompts when running my commands, I tried this one but it did not work. Please help me for any way out. #!/bin/bash #!/usr/bin/expect cd ~/workspace/mimosanetworks_mimosa-nms ls -ltr ... (5 Replies)
Discussion started by: sandy-sm
5 Replies

10. UNIX for Beginners Questions & Answers

Problems executing an interactive shell script

I am new to Unix shell and to this forum. I am having some trouble executing an interactive shell script that I have written using Mac TextEdit that takes a user input via terminal of a file type (jpg or gif) and then activates a script that will iterate through a folder of unsorted file types... (4 Replies)
Discussion started by: Braveheart
4 Replies
Tcl_Main(3)						      Tcl Library Procedures						       Tcl_Main(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tcl_Main, Tcl_SetMainLoop - main program and event loop definition for Tcl-based applications SYNOPSIS
#include <tcl.h> Tcl_Main(argc, argv, appInitProc) Tcl_SetMainLoop(mainLoopProc) ARGUMENTS
int argc (in) Number of elements in argv. char *argv[] (in) Array of strings containing command-line arguments. Tcl_AppInitProc *appInitProc (in) Address of an application-specific initialization procedure. The value for this argument is usually Tcl_AppInit. Tcl_MainLoopProc *mainLoopProc (in) Address of an application-specific event loop procedure. _________________________________________________________________ DESCRIPTION
Tcl_Main can serve as the main program for Tcl-based shell applications. A "shell application" is a program like tclsh or wish that sup- ports both interactive interpretation of Tcl and evaluation of a script contained in a file given as a command line argument. Tcl_Main is offered as a convenience to developers of shell applications, so they do not have to reproduce all of the code for proper initialization of the Tcl library and interactive shell operation. Other styles of embedding Tcl in an application are not supported by Tcl_Main. Those must be achieved by calling lower level functions in the Tcl library directly. The Tcl_Main function has been offered by the Tcl library since release Tcl 7.4. In older releases of Tcl, the Tcl library itself defined a function main, but that lacks flexibility of embedding style and having a function main in a library (particularly a shared library) causes problems on many systems. Having main in the Tcl library would also make it hard to use Tcl in C++ programs, since C++ programs must have special C++ main functions. Normally each shell application contains a small main function that does nothing but invoke Tcl_Main. Tcl_Main then does all the work of creating and running a tclsh-like application. Tcl_Main is not provided by the public interface of Tcl's stub library. Programs that call Tcl_Main must be linked against the standard Tcl library. Extensions (stub-enabled or not) are not intended to call Tcl_Main. Tcl_Main is not thread-safe. It should only be called by a single master thread of a multi-threaded application. This restriction is not a problem with normal use described above. Tcl_Main and therefore all applications based upon it, like tclsh, use Tcl_GetStdChannel to initialize the standard channels to their default values. See Tcl_StandardChannels for more information. Tcl_Main supports two modes of operation, depending on the values of argc and argv. If the first few arguments in argv match ?-encoding name? fileName, where fileName does not begin with the character -, then fileName is taken to be the name of a file containing a startup script, and name is taken to be the name of the encoding of the contents of that file, which Tcl_Main will attempt to evaluate. Otherwise, Tcl_Main will enter an interactive mode. In either mode, Tcl_Main will define in its master interpreter the Tcl variables argc, argv, argv0, and tcl_interactive, as described in the documentation for tclsh. When it has finished its own initialization, but before it processes commands, Tcl_Main calls the procedure given by the appInitProc argu- ment. This procedure provides a "hook" for the application to perform its own initialization of the interpreter created by Tcl_Main, such as defining application-specific commands. The procedure must have an interface that matches the type Tcl_AppInitProc: typedef int Tcl_AppInitProc(Tcl_Interp *interp); AppInitProc is almost always a pointer to Tcl_AppInit; for more details on this procedure, see the documentation for Tcl_AppInit. When the appInitProc is finished, Tcl_Main enters one of its two modes. If a startup script has been provided, Tcl_Main attempts to evalu- ate it. Otherwise, interactive mode begins with examination of the variable tcl_rcFileName in the master interpreter. If that variable exists and holds the name of a readable file, the contents of that file are evaluated in the master interpreter. Then interactive opera- tions begin, with prompts and command evaluation results written to the standard output channel, and commands read from the standard input channel and then evaluated. The prompts written to the standard output channel may be customized by defining the Tcl variables tcl_prompt1 and tcl_prompt2 as described in the documentation for tclsh. The prompts and command evaluation results are written to the standard output channel only if the Tcl variable tcl_interactive in the master interpreter holds a non-zero integer value. Tcl_SetMainLoop allows setting an event loop procedure to be run. This allows, for example, Tk to be dynamically loaded and set its event loop. The event loop will run following the startup script. If you are in interactive mode, setting the main loop procedure will cause the prompt to become fileevent based and then the loop procedure is called. When the loop procedure returns in interactive mode, interac- tive operation will continue. The main loop procedure must have an interface that matches the type Tcl_MainLoopProc: typedef void Tcl_MainLoopProc(void); Tcl_Main does not return. Normally a program based on Tcl_Main will terminate when the exit command is evaluated. In interactive mode, if an EOF or channel error is encountered on the standard input channel, then Tcl_Main itself will evaluate the exit command after the main loop procedure (if any) returns. In non-interactive mode, after Tcl_Main evaluates the startup script, and the main loop procedure (if any) returns, Tcl_Main will also evaluate the exit command. SEE ALSO
tclsh(1), Tcl_GetStdChannel(3), Tcl_StandardChannels(3), Tcl_AppInit(3), exit(n) KEYWORDS
application-specific initialization, command-line arguments, main program Tcl 8.4 Tcl_Main(3)
All times are GMT -4. The time now is 12:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy