Visit Our UNIX and Linux User Community


Get values from a file and the name of the shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get values from a file and the name of the shell
# 1  
Old 09-28-2009
Get values from a file and the name of the shell

I have 2 questions for which I thank for your help
Question 1)
In the file A, i have a list of email addresses
> ex: $ cat a
> alfa.beta @ gmail.com, user.client @ hotmail.com, @ yahoo.com test.dummy

I want to use the values that are within the file A, in a specific instruction eg
mail alfa.beta@gmail.com, user.client@hotmail.com, test.dummy@yahoo.com <$ MAIL_FILE2

Suggestions?

Question 2)
In each shell I want to create a log with the name of the shell (eg <shell_name>. Log) in order to standardize the development, the name of the shell should be automatically getting inside the shell.
Eg: MyLOG=/DIRECTORY/ $shell_name.log

Inside the shell, there is a variable where i could get the name of the shell?
Suggestions?


Thanks for your supported
# 2  
Old 09-28-2009
Quote:
Originally Posted by RMSoares
I have 2 questions for which I thank for your help
Question 1)
In the file A, i have a list of email addresses
> ex: $ cat a
> alfa.beta @ gmail.com, user.client @ hotmail.com, @ yahoo.com test.dummy

I want to use the values that are within the file A, in a specific instruction eg
mail alfa.beta@gmail.com, user.client@hotmail.com, test.dummy@yahoo.com <$ MAIL_FILE2

Suggestions?

If there is just one line in the file:

Code:
read list < FILENAME
mail $list < "$MAIL_FILE2 "



---------- Post updated at 01:49 PM ---------- Previous update was at 11:25 AM ----------

Quote:
Originally Posted by RMSoares
In each shell I want to create a log with the name of the shell (eg <shell_name>. Log) in order to standardize the development, the name of the shell should be automatically getting inside the shell.
Eg: MyLOG=/DIRECTORY/ $shell_name.log

Inside the shell, there is a variable where i could get the name of the shell?

Some shells have a variable containing the version. You can use that to determine the shell:

Code:
[ -n "$BASH_VERSION" ] && shell=bash
[ -n "$KSH_VERSION" ] && shell=pdksh

Or:

Code:
shell=$( ps -o comm $$ | { read; read comm; echo "$comm"; } )

# 3  
Old 09-28-2009
Chris,
I think you've forgotten '-p' - at least on Solaris:
Code:
shell=$( ps -o comm -p $$ | { read; read comm; echo "$comm"; } )


Previous Thread | Next Thread
Test Your Knowledge in Computers #198
Difficulty: Easy
Bash ranked in the top 20 programming languages according to the TIOBE Index for October 2019.
True or False?

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Reading XML file and print the values in the text file using Linux shell script

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (1 Reply)
Discussion started by: sravanreddy
1 Replies

2. Shell Programming and Scripting

Passing values to an XML file from shell script

:wall: Hi, I have an XML file with 5 tags. I need to pass values to the XML file from a shell script that will replace values in 2 of the tags. I cannot hardcode the tag values in XML and use replace command in script as the values are likely to change. Please help !!!!!!!!!!! (2 Replies)
Discussion started by: Monalisaa
2 Replies

3. Shell Programming and Scripting

Read in shell variable values from a file

Hello, I have a simple script that runs an application, # these arguments have the same value for all splits ARCH=12.11.1 BATCHES=50 EPOCHS=5000 LEARN_MODE=ONLINE LEARN_RATE=0.25 PROJ=02_BT_12.11.1.proj echo "processing split A on hex" cd A/ DATA_SET=S2A_v1_12.1.1_1... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

4. Shell Programming and Scripting

Query the table and return values to shell script and search result values from another files.

Hi, I need a shell script, which would search the result values from another files. 1)execute " select column1 from table_name" query on the table. 2)Based on the result, need to be grep from .wft files. could please explain about this.Below is the way i am using. #!/bin/sh... (4 Replies)
Discussion started by: Rami Reddy
4 Replies

5. Shell Programming and Scripting

reading the values from a file in C Shell for loop

Hi All, I need small help on for loop syntax in C shell. How can we read the values from a file (line by line) through C shell loop. For Ex: $Cat file1 data1 data2 data3 data4 $ I have to print those values in a variable and have to perform some steps... Can anyone help on... (2 Replies)
Discussion started by: raghu.iv85
2 Replies

6. Shell Programming and Scripting

Store values from a file into an array variable in Shell

Dear All, I have been trying to do a simple task of extracting 2 fields from the file (3 rows) and store it in an array variable. I tried with: #! /bin/bash ch=`cut -f10 tmp.txt` counter=0 for p in $pid do c=${ch} echo "$c ..$counter" counter=$((counter+1))... (2 Replies)
Discussion started by: ezhil01
2 Replies

7. Shell Programming and Scripting

How can I read values from a CSV file using Shell?

SHELL SCRIPT Hi, I have a file in which contents are as follows: 9999,abdc,123 9988,aba_12,2323 and so on I want to read the contents of this file such that i can do echo "This is $a followed by $b an then $c" I tried the following but id did not work cat test | cut -d ',' -f1|... (7 Replies)
Discussion started by: mayanksargoch
7 Replies

8. Shell Programming and Scripting

How to check the repetition values in a file using bourne shell

Hi all, I have a scenario, like consider a file abc.txt, inside abc.txt, the contents is value1 = aaa, value2 = bbb, value3 = ccc, value1 = ddd. In this situation i need to throw an error for the repeatation of keys like "value1" is repeating twice. how to handle this using bourne... (1 Reply)
Discussion started by: Nandagopal
1 Replies

9. Shell Programming and Scripting

update a file with values from other file in shell bash

Hello I need to write a shell script to update properties between files. I have 2 files as follow: file1 urlWebserviceCheckAddress^=McoConfigGlobal.commonGLOBALUrlWebservice file 2 urlWebserviceCheckAddress=http://localhost:8080/tags Both files containt the same properties... (1 Reply)
Discussion started by: teodora
1 Replies

Featured Tech Videos