Sponsored Content
Full Discussion: arguments in sourcing file
Top Forums UNIX for Dummies Questions & Answers arguments in sourcing file Post 54743 by Nathe on Monday 23rd of August 2004 09:41:02 AM
Old 08-23-2004
Thanks, but in fact I want to source a file which has some arguments.

I want to do:

source myfile arg1 arg2

and in myfile:

set var1=$arg1
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sourcing the .bashrc

Hello, I am quite new to Linux... I need to set some aliases and I can't get it to work. Can somebody tell me what's wrong? I modified the .bashrc file in my home directory. I added: alias pmv= '/home/vera/MGLTools-1.4.5/share/bin/pmv' saved it and ran source .bashrc The shell... (3 Replies)
Discussion started by: Nusy
3 Replies

2. Shell Programming and Scripting

Help with Nested Sourcing files.

Hi, I have a script #!/bin/ksh #reading parameters. . FileA Echo ...... ...... File A has all parameters. FileA: Infile=xyz.com outfile=abc.com #Userid file . FileB FileB: (2 Replies)
Discussion started by: pinnacle
2 Replies

3. Shell Programming and Scripting

sourcing .profile for other users

Hi Team, Thank you for your time. i have a situation where the user IDs of the applicatio users have been locked down to Read only. Hence I am writing a script to invoke their old .profile every time they login. My problem is : when i run . $userpath/.profile from within the ksh script... (9 Replies)
Discussion started by: anitha111
9 Replies

4. Red Hat

Crontab sourcing PATH?

Hi, Im trying to run script A which requires path /sbin. I have a crontab entry to run script A every 10 minutes. Script A is executed fine by cron, but because script A requires /sbin in its path it fails to run. My situation is script A get overwritten from time to time so I can't modify... (4 Replies)
Discussion started by: wilsonee
4 Replies

5. Shell Programming and Scripting

Sourcing as root automatically

Hey everyone! I have my .bash_profile file which is read automatically when I launch Terminal therefore I can run my own functions. BUT. When I do: sudo -s sudo su sudo su - No matter what I do, I can't get the .bash_profile file to be sourced automatically so I end up having to run... (2 Replies)
Discussion started by: dasx
2 Replies

6. Shell Programming and Scripting

Sourcing variables from another script

My manager required that i keep the hostnames and username and password in a separate file when creating my sftp script. (Don't mention passwords and sftp...I've talk to him about this several times) I have a list of hostnames that have to be read in a loop in my main script. I don't know... (3 Replies)
Discussion started by: MJCreations
3 Replies

7. UNIX for Dummies Questions & Answers

Question On Sourcing Variables

I have 2 scripts first script would call second script. test1.sh #!/bin/bash logfile=`basename $0`.log echo "First File" >> $logfile TIME=`ls -lu array.ksh | awk '{print $6" "$7" "$8}'` . /home/infrmtca/bin/Test/test2.sh #/home/infrmtca/bin/Test/test2.sh test2.sh #!/bin/bash... (1 Reply)
Discussion started by: Ariean
1 Replies

8. Shell Programming and Scripting

Sourcing Env file with eval works with ksh but not BASH

Hi, I am running this on Redhat 5.10 I have a simple test script called test.sh which has the following contents and it uses the BASH shebang. ------------------------------------------------------------- #!/bin/bash eval `/tmp/filereader.pl /tmp/envfile.txt` echo "TESTPATH=$TESTPATH" ... (28 Replies)
Discussion started by: waavman
28 Replies

9. Shell Programming and Scripting

Issue with sourcing a file

I have a issue.sh script more issue.sh #!/bin/bash -e echo "start" source ~/.moht echo "end" Contents of ~/.moht are as below more ~/.moht umask 022 export EDITOR=vi SYSNM=`uname -n` UID=`id` HOST=`hostname` Executing of issue.sh throws the below error (1 Reply)
Discussion started by: mohtashims
1 Replies

10. UNIX for Beginners Questions & Answers

Sourcing file from parent directory bash

"Debian 9 64x - LXDE" I try to source a file from my parent directory: #!/bin/bash #source.bash . ../links.bash but i get "file not found". I tried . "../links.bash" and . '../links.bash'. I got on all methods the same result. If i use the absolute path it works, but i don't want to... (4 Replies)
Discussion started by: int3g3r
4 Replies
GETENV(3)						   BSD Library Functions Manual 						 GETENV(3)

NAME
getenv, putenv, setenv, unsetenv -- environment variable functions LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdlib.h> char * getenv(const char *name); int setenv(const char *name, const char *value, int overwrite); int putenv(char *string); int unsetenv(const char *name); DESCRIPTION
These functions set, unset and fetch environment variables from the host environment list. The getenv() function obtains the current value of the environment variable, name. The application should not modify the string pointed to by the getenv() function. The setenv() function inserts or resets the environment variable name in the current environment list. If the variable name does not exist in the list, it is inserted with the given value. If the variable does exist, the argument overwrite is tested; if overwrite is zero, the variable is not reset, otherwise it is reset to the given value. The putenv() function takes an argument of the form ``name=value'' and puts it directly into the current environment, so altering the argu- ment shall change the environment. If the variable name does not exist in the list, it is inserted with the given value. If the variable name does exist, it is reset to the given value. The unsetenv() function deletes all instances of the variable name pointed to by name from the list. If corruption (e.g., a name without a value) is detected while making a copy of environ for internal usage, then setenv(), unsetenv() and putenv() will output a warning to stderr about the issue, drop the corrupt entry and complete the task without error. RETURN VALUES
The getenv() function returns the value of the environment variable as a NUL-terminated string. If the variable name is not in the current environment, NULL is returned. The setenv(), putenv(), and unsetenv() functions return the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
[EINVAL] The function getenv(), setenv() or unsetenv() failed because the name is a NULL pointer, points to an empty string, or points to a string containing an ``='' character. The function putenv() failed because string is a NULL pointer, string is without an ``='' character or ``='' is the first character in string. This does not follow the POSIX specification. [ENOMEM] The function setenv(), unsetenv() or putenv() failed because they were unable to allocate memory for the environment. SEE ALSO
csh(1), sh(1), execve(2), environ(7) STANDARDS
The getenv() function conforms to ISO/IEC 9899:1990 (``ISO C90''). The setenv(), putenv() and unsetenv() functions conforms to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
The functions setenv() and unsetenv() appeared in Version 7 AT&T UNIX. The putenv() function appeared in 4.3BSD-Reno. Until FreeBSD 7.0, putenv() would make a copy of string and insert it into the environment using setenv(). This was changed to use string as the memory location of the ``name=value'' pair to follow the POSIX specification. BUGS
Successive calls to setenv() that assign a larger-sized value than any previous value to the same name will result in a memory leak. The FreeBSD semantics for this function (namely, that the contents of value are copied and that old values remain accessible indefinitely) make this bug unavoidable. Future versions may eliminate one or both of these semantic guarantees in order to fix the bug. BSD
June 20, 2007 BSD
All times are GMT -4. The time now is 03:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy