The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > SUN Solaris
.
google unix.com



SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems .

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
passing runtime arguments to a shell script... santy Shell Programming and Scripting 10 01-09-2009 10:47 PM
passing arguments from shell to java kenpeter UNIX for Dummies Questions & Answers 3 05-19-2008 06:54 PM
Passing blank arguments to a script rm-r UNIX for Advanced & Expert Users 7 01-08-2008 08:56 PM
Problem with scheduling a shell script on cygwin using cron shash UNIX for Dummies Questions & Answers 4 08-09-2007 06:08 PM
Passing arguments to a script Kevin Pryke Shell Programming and Scripting 3 06-14-2002 09:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-27-2008
weblogicsupport weblogicsupport is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 5
Passing arguments to a shell script from file while scheduling in cron

Hi,

I have a shell script Scp_1.sh for which I have to pass 2 arguments to run.

I have another script Scp_2.sh which in turns calls script Scp_1.sh inside.

How do I make Scp_1.sh script to read arguments automatically from a file, while running Scp_2.sh?

--

Weblogic Support
  #2 (permalink)  
Old 01-27-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
You're thinking backwards. scp_1.sh should simply expect two arguments all the time. scp_2.sh should read the arguments from a file and pass them to scp_1.sh. Something like this:
#! /usr/bin/ksh
read arg1 arg2 < /path/to/a_file
/path/to/scp_1.sh $arg1 $arg2
exit $?

$? is the exit code from scp_1, so that "exit $?" just makes scp_2.sh duplicate scp_1.sh's exit code.
  #3 (permalink)  
Old 01-27-2008
weblogicsupport weblogicsupport is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 5
Thanks for the reply.

So from what I understand

if Scp_1.sh expects two arguments line arg1=env (for eg: UAT) and arg2=path (for eg: /var/tmp)

so the content of file from which the script reads should be of bfelow ormat

cat filename.txt
UAT /var/tmp

(UAT then space & PATH)

Please correct me on this.


--

Weblogic Support
  #4 (permalink)  
Old 01-27-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
Quote:
Originally Posted by weblogicsupport View Post
Thanks for the reply.

So from what I understand

if Scp_1.sh expects two arguments line arg1=env (for eg: UAT) and arg2=path (for eg: /var/tmp)

so the content of file from which the script reads should be of bfelow ormat

cat filename.txt
UAT /var/tmp

(UAT then space & PATH)

Please correct me on this.


--

Weblogic Support
Yes that would be the correct format of filename.txt because IFS is set to a space. If IFS were a colon ":" filename.txt would be

cat filename.txt
UAT:/tmp
  #5 (permalink)  
Old 01-27-2008
weblogicsupport weblogicsupport is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 5
Thanks a lot !!

--

Weblogic Support
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0