interactive scripts with user input that includes quotes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting interactive scripts with user input that includes quotes
# 1  
Old 10-17-2012
interactive scripts with user input that includes quotes

I'm writing a basic ldapsearch script that prompts the user for their search criteria. The input they're being asked for is the search filter portion of the ldapsearch command. This string must be quoted. When the script executes the command it returns nothing. If I hard code a search filter it works fine. Snippet below. Any ideas?

Code:
# Search criteria
echo "Enter the attribute and value you wish to search for, e.g. \""cn=firstname lastname\"".  Be sure to enclose in quotes per example."
read SEARCHCRITERIA
echo "You entered ${SEARCHCRITERIA}"
idsldapsearch -h localhost -b o=searchbase ${SEARCHCRITERIA}

sample script execution (bold text is user input)
Code:
[root@host01 ~]# ./lsearch.sh
Enter the attribute and value you wish to search for, e.g. "cn=firstname lastname"".  Be sure to enclose in quotes per example.
"cn=first last"
You entered "cn=first last"
[root@usdl2-ln00-ap01 ~]#

I'm tracking down in the log file what is actually get sent. Haven't got there yet, it has limited access.

Last edited by Scott; 10-17-2012 at 12:59 PM.. Reason: Please use code tags
# 2  
Old 10-17-2012
Just a suggestion: don't have the user include the quotes. Have he script add the quotes to what is entered if you need to.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Recording user input from interactive shell script

Hello, I want to start out by saying that I am fairly new to scripting and am looking for someone that can point me in the right direction. Basically what I need is a way to run a interactive script that will prompt users with questions weather that be yes/no or a specific answer.. I want to be... (3 Replies)
Discussion started by: shoutcast
3 Replies

2. Shell Programming and Scripting

Bash -c interactive scripts

i have to run the following script through a pipe: script.sh: #!/bin/bash echo "Hello World" echo -e "The \033 here's how its currently being run: bash -c "$(cat script.sh)" This is an interactive script. the problem is, when i run it this way, if you go to another terminal and... (4 Replies)
Discussion started by: SkySmart
4 Replies

3. Shell Programming and Scripting

Identifying interactive scripts

so for the purposes of this thread, interactive scripts are shell scripts that prompts for a response from a user and then waits for the user to enter a response before proceeding. now, from my understanding of this, the one common string i can expect to find in all interactive scripts is some... (1 Reply)
Discussion started by: SkySmart
1 Replies

4. Shell Programming and Scripting

Bash interactive scripts

i have a script that contains: script.sh #!/bin/bash echo -e "\t\t\t0. Exit" echo -e "\t\t\t1. Help" echo -e "\t\t\t2. Notes" echo -e "\t\t\t3. Classes" echo "${newline}" echo -n -e "\t Please enter option number : " read Type case $Type in 1) clear ... (1 Reply)
Discussion started by: SkySmart
1 Replies

5. UNIX for Beginners Questions & Answers

Linux Console for Interactive Input Script

Hi there, How do I enter command to the interactive console. I was able to do it via the first line. What if I have more lines to input into the interactive console from line 3 onwards. Is there a more easier way? (echo -e "load openvas" ; echo -e "openvas_help") | msfconsole ... (4 Replies)
Discussion started by: alvinoo
4 Replies

6. Shell Programming and Scripting

Interactive scripts for Oracle

Hello friends, I am a ORACLE user, we have some internal database file, lets say "demo.config" and an internal tool to patch this file....lets call that tool as "dbfixer". We have 100's-1000's of such files "demo.config" which need to get patched by the tool. So we need to write a script ...... (1 Reply)
Discussion started by: Newbie456267uni
1 Replies

7. Shell Programming and Scripting

[/bin/sh] passing parameters with quotes between 2 scripts

Hi, I have a first shell script (/bin/sh) that receives some paremeters. This is only an example (there are more parameters in fact and this one is among them): -header "This is a test" This script calls a secund shell script (/bin/sh) with the same parameters. But, quotes disappear as I would... (0 Replies)
Discussion started by: velo_love
0 Replies

8. Shell Programming and Scripting

put an interactive script in background after taking input

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)
Discussion started by: epsilonaurigae
7 Replies

9. Shell Programming and Scripting

Automating interactive scripts

Hi all, I am trying to write a program that will automate interactive scripts that use 'pkgadd'. Easily enough I can use 'pkgask' and a response file for most of what I want to do, but unfortunately there are parts of some pkg installations that are configured to only take input from /dev/tty!!... (2 Replies)
Discussion started by: bookoo
2 Replies
Login or Register to Ask a Question