Sponsored Content
Top Forums Shell Programming and Scripting How to automatically pass 'multiple' user inputs Post 302690861 by Corona688 on Thursday 23rd of August 2012 12:51:49 PM
Old 08-23-2012
You can also do something like this:

Code:
./myscript.sh <<EOF
name
age
EOF

Or if you can rewrite the script, just pass them in as parameters:
Code:
#!/bin/sh

NAME="$1"
AGE="$2"

Code:
./myscript name age

This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multiple Inputs

Have tried the search, but nothing resembles what I'd like to accomplish. I am attempting to write a script that will allow the user to input a list of data at the command prompt, then the data is used by another script for processing. I am allowing the user a list of 10 members in order to... (4 Replies)
Discussion started by: douknownam
4 Replies

2. Shell Programming and Scripting

limiting data inputs for the user

if my user has to enter the name of months to carry out a search how can I limit the input values to only the month names and nothing else? so far my input criteria for the user is this: i would like it so the user can only enter the months in the way i have stated. otherwise they would... (11 Replies)
Discussion started by: amatuer_lee_3
11 Replies

3. Shell Programming and Scripting

Scripting A Source File With User Inputs

I need to write what I thought would be a fairly simple 2-line UNIX script. It can be written PERL, csh, ksh...or whatever is easiest. The entire script will be: Begin Scipt source MySourceFile execute MyExecutable.exe End Script The problem is that MySourceFile can not be... (1 Reply)
Discussion started by: MMorrison
1 Replies

4. Shell Programming and Scripting

How to automate user's inputs.

Hi Friends, I am wrinting a shell script MorningChecks.sh which will call another script StartServer.sh. But the latter script requires user's inputs to complete. I want to automate this. So can you please let me how this can be achieved? Any help would be highly appereciated. ... (3 Replies)
Discussion started by: singh.chandan18
3 Replies

5. Shell Programming and Scripting

Take 10 user inputs and output to file?

I want a script that will prompt a user to enter 10 numbers and out put them into a file. This what I have so far, but isn't working. I'm guessing it's something easy I'm not seeing. Thanks for any help. #!/usr/bin/ksh echo "Enter 10 numbers" for i in 1 2 3 4 5 6 7 8 9 10 do read .... ... (8 Replies)
Discussion started by: AxlVanDamme
8 Replies

6. Shell Programming and Scripting

Storing user inputs into a file

Hi, Am trying to store the user inputs into a file, but the below code will store only the first line of the values. I need to store all the user input values which may contain one or more lines. Thanks in advance. echo "please enter file names"; read name; echo $name>/tmp/test (11 Replies)
Discussion started by: rogerben
11 Replies

7. UNIX for Dummies Questions & Answers

How to give multiple inputs to a shell script

Got struck while trying to write a shell script which should automatically give input. While running a script for eg: (adpatch.sh) It Prompts for Multiple inputs like: Do you currently have files used for installing or upgrading the database installed in this APPL_TOP ? need to give... (2 Replies)
Discussion started by: abdmoha
2 Replies

8. Shell Programming and Scripting

Script to cp files that user inputs

Need a bash script that will ask the user: Which Files Would you like to copy? Then the user would input the filenames (space seperated, all lowercase) The script would then cp each file to /data/backup/ and also wc the files to std output. (to see how many lines each file has) Should go... (5 Replies)
Discussion started by: ajp7701
5 Replies

9. UNIX for Beginners Questions & Answers

Password generator with user inputs

Hi, I am new to bash scripting and i wanted to make a bash script that will generate a password for a user. The user must enter his/her name and the url of the site the password is used for. And the script will generate a password with those two elements in the password. So if the url is... (0 Replies)
Discussion started by: Kvr123
0 Replies

10. Shell Programming and Scripting

Need to prepare a CSV table with inputs from multiple files

Hi, We have thousands of Video files and we need to prepare a table with few of it's parameters/values from their Mediainfo output. Here I have 3 sample mediainfo output text files named Vid1, Vid2 & Vid3 so on... (such we have thousands) and each file has exactly 3 lines. $ ls... (6 Replies)
Discussion started by: prvnrk
6 Replies
SETMODE(3)						   BSD Library Functions Manual 						SETMODE(3)

NAME
getmode, setmode -- modify mode bits LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <unistd.h> void * setmode(const char *mode_str); mode_t getmode(const void *set, mode_t mode); DESCRIPTION
The setmode() function accepts a string representation of a file mode change, compiles it to binary form, and returns an abstract representa- tion that may be passed to getmode(). The string may be an numeric (octal) or symbolic string of the form accepted by chmod(1), and may rep- resent either an exact mode to set or a change to make to the existing mode. The getmode() function adjusts the file permission bits given by mode according to the compiled change representation set, and returns the adjusted mode. While only the permission bits are altered, other parts of the file mode, particularly the type, may be examined. Because some of the possible symbolic values are defined relative to the file creation mask, setmode() may call umask(2), temporarily chang- ing the mask. If this occurs, the file creation mask will be restored before setmode() returns. If the calling program changes the value of its file creation mask after calling setmode(), setmode() must be called again to recompile the mode string if getmode() is to modify future file modes correctly. If the mode passed to setmode() is invalid, setmode() returns NULL. EXAMPLES
The effects of the shell command 'chmod a+x myscript.sh' can be duplicated as follows: const char *file = "myscript.sh"; struct stat st; mode_t newmode; stat(file, &st); newmode = getmode(setmode("a+x"), st.st_mode); chmod(file, newmode); ERRORS
The setmode() function may fail and set errno for any of the errors specified for the library routines malloc(3) or strtol(3). In addition, setmode() will fail and set errno to: [EINVAL] The mode argument does not represent a valid mode. SEE ALSO
chmod(1), stat(2), umask(2), malloc(3) HISTORY
The getmode() and setmode() functions first appeared in 4.4BSD. BUGS
Each call to setmode allocates a small amount of memory that there is no correct way to free. The type of set should really be some opaque struct type used only by these functions rather than void *. BSD
January 4, 2009 BSD
All times are GMT -4. The time now is 09:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy