Multiple variables options


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple variables options
# 1  
Old 05-11-2013
Multiple variables options

Hi I'm looking to take a user input and use it to effect just two characters in a command rather than having multiple functions for each one.

Code:
function baseencode() {
echo "This function handles the following: $YELLOW base64 base32 base16 $NORMAL"
echo "$GREEN Select 64 32 or 16 $NORMAL"
read B
echo "Enter text to be encrypted"
read baseplain
sleep 1
read baseencoded <<< $(python -c "import base64; print base64.b**encode('''$baseplain''')")
echo "$RED Converted string: $baseencoded $NORMAL"

I want to make so the two asterisks become whatever the user inputs.

Last edited by Scrutinizer; 05-12-2013 at 10:01 AM.. Reason: Changed icode tags to code tags
# 2  
Old 05-11-2013
Quote:
Originally Posted by 3therk1ll
Hi I'm looking to take a user input and use it to effect just two characters in a command rather than having multiple functions for each one.



function baseencode() {
echo "This function handles the following: $YELLOW base64 base32 base16 $NORMAL"
echo "$GREEN Select 64 32 or 16 $NORMAL"
read B
echo "Enter text to be encrypted"
read baseplain
sleep 1
read baseencoded <<< $(python -c "import base64; print base64.b**encode('''$baseplain''')")
echo "$RED Converted string: $baseencoded $NORMAL"



I want to make so the two asterisks become whatever the user inputs.
Try changing base64.b**encode to base64.b${B}encode.
# 3  
Old 05-11-2013
Perfect, cheers dude.
Solved.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assigning multiple column's value from Oracle query to multiple variables in UNIX

Hi All, I need to read values of 10 columns from oracle query and assign the same to 10 unix variables. The query will return only one record(row). I tried to append all these columns using a delimiter(;) in the select query and assign the same to a single variable(V) in unix. I thought I... (3 Replies)
Discussion started by: hkrishnan91
3 Replies

2. Shell Programming and Scripting

Using getopts for handling multiple options

Hi Guys, I have created a script for our automated DB creation, it works fine with default option(-d). $ ./test_db.ksh -d abc 11 dev -d is Default option ORACLE_SID=abc ORACLE_VERSION=11 ENV_TYPE=dev For creating a customized DB, i thought of giving the user different options.... (8 Replies)
Discussion started by: veeresh_15
8 Replies

3. Shell Programming and Scripting

Reading multiple values from multiple lines and columns and setting them to unique variables.

Hello, I would like to ask for help with csh script. An example of an input in .txt file is below, the number of lines varies from file to file and I have 2 or 3 columns with values. I would like to read all the values (probably one by one) and set them to independent unique variables that... (7 Replies)
Discussion started by: FMMOLA
7 Replies

4. Shell Programming and Scripting

Multiple search options in find command

Hi, I'd like find multiple file options to fetch different types of files. find /path...// -type f -name "*.log" -o -name "*.req" -o -name "*.txt" -mtime +5 -exec ls -l {} \; Where as in the above command only the last .txt files its retriving but not .log and .req files can body help... (1 Reply)
Discussion started by: Y.balakrishna
1 Replies

5. Shell Programming and Scripting

SFTP multiple options

Hi, I am trying to SFTP files in a script that i created. But the problem is i have to use -oPort and -b together. how can i get this done. I have tried as below command in my script but with no luck sftp -oPort=102 -b <batchfilename> username@server sftp -oPort=102 -ob... (1 Reply)
Discussion started by: ramkiran77
1 Replies

6. Shell Programming and Scripting

Running a script with multiple variables like 25 variables.

Hi All, i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way?? #!/bin/ksh ##script is sample.ksh age=$1 gender=$2 class=$3 . . .... (3 Replies)
Discussion started by: Lakshman_Gupta
3 Replies

7. Shell Programming and Scripting

find command to use multiple -exec options

Hello All, Is there a way to make exec do a couple of operations on a single input from find? For example, find . -type d -exec ls -l "{}" ";" I would like to give the result of each "ls -l" in the above to a wc. Is that possible? I want to ls -l | wc -l inside exec. How do I... (1 Reply)
Discussion started by: prasanna1157
1 Replies

8. UNIX for Advanced & Expert Users

shred multiple options

I've created a wxpython gui for the shred command. I can successfully mix and match all the shred options except two: -size and --random-source. (Man page definitions below). -size and --random-source seem to only work when they are used as the sole option passed. For example, I can zero a... (0 Replies)
Discussion started by: codecellar
0 Replies

9. UNIX for Advanced & Expert Users

Multiple runlevel options at Bootup

Is it possible to give multiple runlevel options during boot up.. When the Welcome screen appears, i want to give multiple runlevel options.. So the user can boot into any desired runlevel he wants.. Found this kinda interesting.. Any hints and solutions please? (2 Replies)
Discussion started by: srikumar_cs
2 Replies

10. Shell Programming and Scripting

Handeling multiple options in script

i need to be able to handel if multiple commands are passed into my script. (ie) -f -r -i . does anyone know a simple solution to handeling this. Thanks (2 Replies)
Discussion started by: virus_stinger
2 Replies
Login or Register to Ask a Question