Sponsored Content
Top Forums Shell Programming and Scripting How can I parse a record found in /etc/passwd into variables? Post 302151338 by shew01 on Friday 14th of December 2007 03:05:47 PM
Old 12-14-2007
How can I parse a record found in /etc/passwd into variables?

I am working with the Oracle 10.2.0.3 job scheduler on Solaris 10, and unfortunately, the scheduler executes scripts in such a way that several default shell environment variables are not defined. For example, $HOME, $USER, and $LOGNAME are missing.

How can I parse the appropriate record in /etc/passwd into the above variables? For example, when the output from "grep oracle /etc/passwd" is:
oracle:x:100:1978::/usr/oracle:/bin/ksh
I need to parse the information so that I can manually export the following variables:
export HOME=/usr/oracle
export USER=oracle
export LOGNAME=oracle
I'm looking for something generic that will enable me to search for any record in /etc/passwd and parse it properly.

Thanks,

J
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do I parse passwords into passwd command.

Do you know of any methods where I can send an input of passwords into the passwd command? For instance, I have a file which has the password stored and I want it to be sent into this command "passwd gilberteu" when it prompts for the new password and subsequently confirming the password that was... (0 Replies)
Discussion started by: gilberteu
0 Replies

2. Shell Programming and Scripting

How to parse a string into variables

I'm working in korn shell and have a variable which contains a string like: aa_yyyymmdd_bbb_ccc_ddd.abc. I want to treat the _ and . as delimiters and parse the string so I end up with 6 values in variables that I can manipulate. My original plan was to use var1=`echo $sting1 | cut -c1-c2` but... (9 Replies)
Discussion started by: aquimby
9 Replies

3. Shell Programming and Scripting

Bash Script to read a file and parse each record

Hi Guys, I am new to unix scripting and I am tasked to parse through a CSV file delimited by #. Sample: sample.csv H#A#B#C D#A#B#C T#A#B#C H = Header D = Detail Record T = Tail What I need is to read the file and parse through it to get the columns. I have no idea on how... (8 Replies)
Discussion started by: 3vilwyatt
8 Replies

4. Shell Programming and Scripting

Want to parse output for variables in Bash

Trying to finish up my script that automates some video encoding work. Situation: There is an MKV file to be transcoded. Problem: MKVINFO will give a bunch of output about an MKV file, included in that output are two lines I am interested in: | + Default duration: 41.708ms (23.976 fps... (9 Replies)
Discussion started by: randyharris
9 Replies

5. UNIX for Dummies Questions & Answers

Parse or cut concat variables to individual values

Hello I need to pass some environment parameters to a datastage job and am getting an error when trying to send the complete concatinated variable. I have decided to parse out just the values and send as parameters but am struggling to find the best way to do this (actually I am not very... (3 Replies)
Discussion started by: LynnC
3 Replies

6. Shell Programming and Scripting

prompt to delete each record when pattern is found

Hello!. I am working on a very simple program and I have been trying different things. This is so far what I have done and there is one small detail that still does not work. It finds all the records in a phonebook per say: ./rem Susan More than one match; Please select the one to remove: ... (3 Replies)
Discussion started by: bartsimpsong
3 Replies

7. Shell Programming and Scripting

Cut fields from /etc/passwd file into variables?

The script must ask the user to enter the user name and check whether the user exists in /etc/passwd (you must allow the partial usernames also). If the username exists, display the details as: List of users Login Name: User ID: ... (3 Replies)
Discussion started by: nobletechnology
3 Replies

8. Linux

Parse ; deliminated variable to create variables

Hi there, would appreciate some help on this parsing problem if anybody can help im trying to parse a variable with the following output, each of the values im trying to parse are deliminated by a ; T192... (8 Replies)
Discussion started by: scottish_jason
8 Replies

9. Shell Programming and Scripting

Parse variables from C++ to shell

Hi All, #include <iostream> int main() { std::int foo = 34; system("mkdir /home/linuxUser/fooDir"); system("vi fooFile") system("write foo in fooFile") foo = 43; foo = read foo from fooFile; std::cout << "foo = " << foo ; } result should be foo = 34 can... (3 Replies)
Discussion started by: linuxUser_
3 Replies

10. Shell Programming and Scripting

Delete only if duplicates found in each record

Hi, i have another problem. I have been trying to solve it by myself but failed. inputfile ;; ID T08578 NAME T08578 SBASE 30696 EBASE 32083 TYPE P func just test func chronology func cholesterol func null INT 30765-37333 INT 37154-37318 Link 5546 Link 8142 (4 Replies)
Discussion started by: redse171
4 Replies
condor_run(1)						      General Commands Manual						     condor_run(1)

Name
       condor_run Submit - a shell command-line as a Condor job

Synopsis
       condor_run [-u universe] "shell command"

Description
       condor_run bundles a shell command line into a Condor job and submits the job. The condor_run command waits for the Condor job to complete,
       writes the job's output to the terminal, and exits with the exit status of the Condor job. No output appears until the job completes.

       Enclose the shell command line in double quote marks, so it may be passed to condor_runwithout modification. condor_runwill not read  input
       from  the  terminal while the job executes. If the shell command line requires input, redirect the input from a file, as illustrated by the
       example

       % condor_run  "myprog < input.data"

       condor_runjobs rely on a shared file system for access to any necessary input files. The current working  directory  of	the  job  must	be
       accessible to the machine within the Condor pool where the job runs.

       Specialized environment variables may be used to specify requirements for the machine where the job may run.

       CONDOR_ARCH

	  Specifies the architecture of the required platform. Values will be the same as the  Arch machine ClassAd attribute.

       CONDOR_OPSYS

	  Specifies the operating system of the required platform. Values will be the same as the  OpSys machine ClassAd attribute.

       CONDOR_REQUIREMENTS

	  Specifies  any additional requirements for the Condor job. It is recommended that the value defined for  CONDOR_REQUIREMENTS be enclosed
	  in parenthesis.

       When one or more of these environment variables is specified, the job is submitted with:

       Requirements = $CONDOR_REQUIREMENTS && Arch == $CONDOR_ARCH && 

	 OpSys == $CONDOR_OPSYS

       Without these environment variables, the job receives the default requirements expression, which requests a machine of the same platform as
       the machine on which condor_runis executed.

       All environment variables set when condor_runis executed will be included in the environment of the Condor job.

       condor_runremoves the Condor job from the queue and deletes its temporary files, if condor_runis killed before the Condor job completes.

Options
       -u universe

	  Submit  the  job  under the specified universe. The default is vanilla. While any universe may be specified, only the vanilla, standard,
	  scheduler, and local universes result in a submit description file that may work properly.

Examples
       condor_runmay be used to compile an executable on a different platform. As an example, first set the environment variables for the required
       platform:

       % setenv CONDOR_ARCH "SUN4u"
       % setenv CONDOR_OPSYS "SOLARIS28"

       Then, use condor_runto submit the compilation as in the following three examples.

       % condor_run  "f77 -O -o myprog myprog.f"

       or

       % condor_run  "make"

       or

       % condor_run  "condor_compile cc -o myprog.condor myprog.c"

Files
       condor_runcreates  the  following  temporary  files in the user's working directory. The placeholder <pid> is replaced by the process id of
       condor_run.

       .condor_run .<pid>

	  A shell script containing the shell command line.

       .condor_submit.<pid>

	  The submit description file for the job.

       .condor_log.<pid>

	  The Condor job's log file; it is monitored by condor_run , to determine when the job exits.

       .condor_out.<pid>

	  The output of the Condor job before it is output to the terminal.

       .condor_error.<pid>

	  Any error messages for the Condor job before they are output to the terminal.

	  condor_run removes these files when the job completes. However, if condor_run fails, it is possible that these files will remain in  the
	  user's working directory, and the Condor job may remain in the queue.

General Remarks
       condor_runis  intended  for  submitting	simple shell command lines to Condor. It does not provide the full functionality of condor_submit.
       Therefore, some condor_submiterrors and system failures may not be handled correctly.

       All processes specified within the single shell command line will be executed on the single machine matched with the job. Condor  will  not
       distribute multiple processes of a command line pipe across multiple machines.

       condor_runwill  use  the  shell	specified  in the  SHELL environment variable, if one exists. Otherwise, it will use /bin/shto execute the
       shell command-line.

       By default, condor_runexpects Perl to be installed in  /usr/bin/perl . If Perl is installed in another path, ask the  Condor  administrator
       to edit the path in the condor_runscript, or explicitly call Perl from the command line:

       % perl path-to-condor/bin/condor_run  "shell-cmd"

Exit Status
       condor_runexits with a status value of 0 (zero) upon complete success. The exit status of condor_runwill be non-zero upon failure. The exit
       status in the case of a single error due to a system call will be the error number ( errno ) of the failed call.

Author
       Condor Team, University of Wisconsin-Madison

Copyright
       Copyright (C) 1990-2012 Condor Team, Computer Sciences Department, University of  Wisconsin-Madison,  Madison,  WI.  All  Rights  Reserved.
       Licensed under the Apache License, Version 2.0.

       See the Condor Version 7.8.2 Manualor http://www.condorproject.org/licensefor additional notices. condor-admin@cs.wisc.edu

								  September 2012						     condor_run(1)
All times are GMT -4. The time now is 09:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy