I was writing a shell script, where i need to run a command through script and then take input from user and later terminate it. i am not sure how to take input in a proper format immediately after a command.
example: below command line is used to import some data in to database (LDAP)
after entering this command it expects the input from user in below format
above LDIF file changes the status of particular user in DataStore (LDAP).
now, my doubt is how to write a script in such a way that it uses the command :
to import LDIF file and then take the input in above format...
If i give the above 4 lines in the same format just after the Ldapmodify command it throws error
Last edited by rbatte1; 01-17-2017 at 01:06 PM..
Reason: Added CODE tags
Unfortunately your request is not clear. Do you want the user sitting in front of the terminal to key in that unusually stritctly formatted, voluminous, and error prone 6 line data record, or do you need to supply that structured text to ldapmodify? Does ldapmodify read from stdin?
And, please use CODE tags as required by forum rules!
I want the user to provide only User ID in the start, later it should take that value in variable.
FYI, ldapmodify command expects an input to be supplied in below form
here if you see in the first line it has something called as "uid", there i want to have the User ID (uid) value inputted by the user, rest things remains the same.
now my doubt is how to supply above 4 lines as input to ldapmodify command.
This will be more clear by looking at the script which i have developed till now, and stuck at that place.
code:
####################################
Thanks,
Mridul Utkarsh
---------- Post updated at 08:36 AM ---------- Previous update was at 08:33 AM ----------
In the above code, case statement (2) - if part has the logic
After this it fails to take input.
Moderator's Comments:
Please use CODE tags as required by forum rules!
Last edited by RudiC; 01-18-2017 at 09:37 AM..
Reason: Added CODE tags.
Please make sure to comply to the the forum rules, in particular: use code tags, and post in an adequate forum, so moderators don't need to clean up after you.
Rg. your problem: the other invocations of ldapmodify seem to be fed input data by passing parameter values; why doesn't that work for the one in question?
If no, can you specify an input file where it searches for data?
For your above setup, did you consider using a bash "here document" (c.f. man bash)?
Hi ,
I am a newbie!!!
I want to develop a script for deleting files older than x days from multiple paths. Now I could reach upto this piece of code which deletes files older than x days from a particular path. How do I enhance it to have an input from a .txt file or a .dat file? For eg:... (12 Replies)
Hi,
I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database.
For instance:
USER CITY
--------- ----------
A CITY_A
B CITY_B
C ... (2 Replies)
Legends,
Please help me to come out of the below Bermuda triangle.
I have four inputs in a shell script: A B C D
Now, If A is passed by user then, B C D will be ignored.
If C is passed by user, then A B D will be ignored.
Regards,
Sandy (11 Replies)
Hi All,
I am facing a problem while taking input from user in Shell Script. Basically , I want to read a file line by line. And I want to remove certain lines of that file.But before removing those lines , I need to ask the user whether user wants to remove the lines. If user inputs "Yes" , the... (3 Replies)
Hi,
I have script which will take a string as input and search in a file.
But when I want to search a pattern which has special characters script is ignoring it.
For example: I want to search a pattern "\.tumblr\.com". shell script is removing \ (backslah) and trying to search... (7 Replies)
i have this basic code that accepts for two input one for the source file and the other is for the target directory. basically it is a simple copy command. the problem is at the end of the execution the second parameter string was passed to first parameter and it displays a message like:
cp:... (3 Replies)
Hi,
I have here a script which is used to purge older files/directories based on defined purge period. The script consists of 45 find commands, where each command will need to traverse through more than a million directories. Therefore a single find command executes around 22-25 mins... (7 Replies)
I am trying to take input from a file and direct it into a bash script. This script is meant to be a foreach loop. I would like the script to process each item in the list one by one and direct the output to a file.
# cat 1loop
#!/bin/bash
# this 2>&1 to redirect STDERR & STDOUT to file... (4 Replies)
i am trying to find a way to put an interactive script in the background after taking input from the user
a few test lines i was trying:
date
echo "Enter location"
LOCATION=
read LOCATION
sleep 100
sleep 200
date
for this small example i want the script to as the user for the... (7 Replies)