Sponsored Content
Top Forums Shell Programming and Scripting Automaticaly create function based off user input Post 303010185 by cmccabe on Thursday 28th of December 2017 08:17:11 AM
Old 12-28-2017
Automaticaly create function based off user input

I am trying to create a bash script that will create new function by using the user input. The below will create the necessary files in the correct format, however when it comes to the # create function I am at a loss.
If the name entered was NEWNAME and the genes were GENE1,GENE2 then two files would be created using NEWNAME. That executes as expected and in the # convert name to lower case, NEWNAME is converted to lowercase as variable string. This variable starts the function. The ... in the code are mostly hardcoded lines that use either NEWNAME or $string in them. I am not sure if this is the best way but maybe its a start. Thank you Smilie.

Code:
#!/bin/bash

# enter name
printf "What is the name of the panel (please use CAPS): "; read name

# enter gene input
printf "%s \n" "Please enter gene(s), use a comma between multiple:" ; IFS="," read -a genes
for (( i = 0; i < ${#genes[@]}; i++ ))
do
    printf "%s\n" "${genes[$i]}" > /home/cmccabe/Desktop/NGS/panels/new.txt
    # remove line endings and trim
     sed 's/\r$//' < /home/cmccabe/Desktop/NGS/panels/new.txt | sed 's/^[ \t]*//;s/[ \t]*$//' > /home/cmccabe/Desktop/NGS/panels/${name}_unix_trim.bed
done

# create total target length for input
awk 'NR==FNR{A[$1];next}$1 in A' /home/cmccabe/Desktop/NGS/panels/${name}_unix_trim.bed /home/cmccabe/Desktop/NGS/bed/bedtools/IDP_total_target_length_by_panel/IDP_unix_trim_total_target_length.bed > /home/cmccabe/Desktop/NGS/bed/bedtools/IDP_total_target_length_by_panel/${name}_unix_trim_total_target_length.bed

#-------------------------------------------------------------------------#
# convert name to lower case
y="$name"
val=$(echo "$y" | tr '[:upper:]' '[:lower:]')
string="$val"

echo "This is the new panel to add" $string

# create function
printf "$string() {"
.....
.....

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create a multi user input form

Hi All, Please ignore if terminology used is incorrect as I am new to Unix. I want to create a Multi user input form which looks something like this: ABCD TOOL Logged User: abcd12 ... (4 Replies)
Discussion started by: vidhu0007
4 Replies

2. Shell Programming and Scripting

Append file based upon user input-- solved

Ok, I have a script with a commandline option that allows the user to add a custom function to the script file. I have tried everything in my limited knowledge of sed to get this to work and keep coming up short. I need sed to search for a line starting with a pattern, I've got that part so far,... (0 Replies)
Discussion started by: DC Slick
0 Replies

3. Shell Programming and Scripting

every time user input create array perl

Hi, How to create array every time user input and store user input and display all array print " Enter input " my @input = split(' ', $input) chmop($input = <STDIN>; foreach ($input) { @array= @input; } print @array"\n"; (1 Reply)
Discussion started by: guidely
1 Replies

4. Shell Programming and Scripting

How to automatically create variables from user input in ksh?

I need some help to write a ksh script. My code so far (pretty bad, sorry): #! /bin/ksh echo "Calculate average" UserDecision=y while test $UserDecision = y do echo "Enter a number: " read Number1 echo "Enter a number: " read Number2 echo "Do you want to enter another number?... (2 Replies)
Discussion started by: johnagar
2 Replies

5. Shell Programming and Scripting

no chance to input passwd when create new user in loop

Hi Dears, I have one script to create new users with information in one plain text file. This script will read all lines in the file and create one users for one line. Sample file: #action;login,full name title,expire date,project +;gmwen,Bruce Wen QA,04/01/2012,BT +;xxdeng,Shown Deng... (4 Replies)
Discussion started by: crest.boy
4 Replies

6. Shell Programming and Scripting

create an array which can store the strings from the user input in shell script

I want to create an array which can store the strings from the user input in shell script . example :- I want to store the 5 fruits name in a single array which the user provides . (1 Reply)
Discussion started by: Pkast
1 Replies

7. Shell Programming and Scripting

Script interacts with user , based on user input it operates

i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled. #!/bin/sh echo " Enter your choice to continue y/Y OR n/N to quit " read A if then echo " user requested to continue " ##some commands... (7 Replies)
Discussion started by: only4satish
7 Replies

8. Homework & Coursework Questions

Function to Check if string input from user is alphabetic only

Good Evening. I'm new to C. Can you please help me. I'm creating an error checking function, user will input a string, this will check if the input is all alphabet or all letters only. If there is a digit or other special char, it will print Error then ask input from user again. Here's my... (1 Reply)
Discussion started by: eracav
1 Replies

9. UNIX for Dummies Questions & Answers

Split files based on user input

Hi All, I have a UNIX script which reads "PxyType" (read PxyType) as input from user and a file (eg : "File.json") with the list all PxyType's. Based on the user input for "PxyType" in "File.json", I want to redirect each matched line to a different file ("File1,2,3,..json"). Can you... (7 Replies)
Discussion started by: Deena1984
7 Replies

10. Shell Programming and Scripting

Bash to search file based off user input then create new file

In the below bash a file is downloaded when the program is opened and then that file is searched based on user input and the result is written to a new file. For example, the bash is opened and the download.txt is downloaded, the user then enters the id (NA04520). The id is used to search... (5 Replies)
Discussion started by: cmccabe
5 Replies
dtsetup(8)						      System Manager's Manual							dtsetup(8)

NAME
dtsetup - Configure and Customize the Common Desktop Environment (CDE) SYNOPSIS
/usr/dt/bin/dtsetup X resources OPTIONS
Specifies the standard X11 resource options. For more information, see the X(1X) reference page. DESCRIPTION
The CDE Setup application, dtsetup, provides you with a mechanism to customize your Common Desktop Environment by using a graphical user interface. It also provides System Administrators a means to create a CDE environment for various types of users. When you invoke the CDE Setup application, a panel of four icons are displayed: Quick Setup, Desktop, Login, and Services. From the Quick Setup icon, you or the system administrator can provide minimal entries to configure CDE. The Desktop icon lets you or the system administrator set up the front panel, establish various window manager resources, define starting applications, and set parameters for the terminal, dtmail, and dtfile applications. The Login icon lets you provide information about your login session, while the system administrator can also set up the system login greetings, and set up the X server configuration. The Services icon has fields for various services configuration. You are restricted to the choice of whether to run the Motif/OpenLook DND gateway. The system administrator has additional choices regarding the ToolTalk Session and ToolTalk Database server, as well as disabling network dependency and allowing inbound remote process execution. The CDE Setup application provides an effortless way of assembling the CDE front panel from available controls. Furthermore, by providing various file names and other specifications, the CDE Setup application allows you to create your own controls. The CDE setup application can be invoked from: The CDE Application Manager. Application Group: System_Admin Desktop_Apps Subgroup: Configuration To start the dtsetup application from the command line, enter /usr/dt/bin/dtsetup. Online help is available for the dxmtools application. To get help, click on any Help button or use the Help pull-down menu. RESTRICTIONS
You must have superuser privileges to access the full functionality of this application. FILES
CDE setup application executable CDE setup online help volume SEE ALSO
Commands: dtlogin(1), ttdbserverd(1), ttsession(1), X(1X), xdm(1X), xprop(1X) Files: dtfpfile(4) Common Desktop Environment: User's Guide Common Desktop Environment: Advanced User's and System Administrator's Guide CDE Companion dtsetup(8)
All times are GMT -4. The time now is 06:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy