- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: To pass a paramenter
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2007 11:29 PM
тАО03-28-2007 11:29 PM
To pass a paramenter
I have a problem to figure out how to pass parameters.
How do I pass value from one shell script to another shell script. The scripts are in C shell.
These are 2 different scripts which will be invoked separetely.
Could you pls help me with this.
Thanks in advance
- Tags:
- csh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2007 11:38 PM
тАО03-28-2007 11:38 PM
Re: To pass a paramenter
something like:
$ cat a.sh
#!/usr/bin/sh
echo "this is shell 1 : parameter $1"
b.sh "$1"
echo "this is shell 1 again"
$ cat b.sh
#!/usr/bin/sh
echo "this is shell 2 : parameter $1"
example:
$ ./a.sh 4
this is shell 1 : parameter 4
this is shell 2 : parameter 4
this is shell 1 again
Please also read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33 on how to reward any useful answers given to your questions.
So far you have only awarded points to one of 10 answers !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 12:02 AM
тАО03-29-2007 12:02 AM
Re: To pass a paramenter
Thanks for u'r answer....but my scripts are called seprately.
For example
a.sh
set var = 1
echo $var
now I want to use this $var in another shell say b.sh, b.sh is not inside a.sh.
Can I do this in C shell scripts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 12:13 AM
тАО03-29-2007 12:13 AM
Re: To pass a paramenter
You can't do this with scripts. You can only do this if you source the file. And you need to be careful what you add to these files.
>Can I do this in C shell scripts?
The real shell syntax is:
$ . a.sh
The scummy C shell syntax is:
% source a.sh
- Tags:
- scummy C shell
- source
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 12:44 AM
тАО03-29-2007 12:44 AM
Re: To pass a paramenter
Use a temp file as an intermediary. Have script1 write the value of $var to the file, and have check if the temp file exists, and assign the stored value to $var if it does.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 04:41 AM
тАО03-29-2007 04:41 AM
Re: To pass a paramenter
a more detailled example for csh (I recommend using tcsh - available at the porting center - as a compatible superset of csh).
a.csh:
set avar=$1
echo "set avar=$avar" >! /tmp/myavar
...
b.csh:
if (-f /tmp/myavar) then
source /tmp/myavar
else
exit 1
endif
set bvar=hello.$avar
echo $bvar
...
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 02:39 PM
тАО03-29-2007 02:39 PM
Re: To pass a paramenter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 04:07 PM
тАО03-29-2007 04:07 PM
Re: To pass a paramenter
http://forums1.itrc.hp.com/service/forums/helptips.do?#33