LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-06-2012, 02:51 AM   #1
prravin1
Member
 
Registered: Feb 2012
Location: India
Posts: 43

Rep: Reputation: Disabled
Unhappy Find path of output generated


I have a script which take the output path as an argument. Now how can i save the complete path of this output folder in a text file in the output folder itself?
 
Old 03-06-2012, 02:58 AM   #2
Slackyman
Member
 
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347

Rep: Reputation: 44
You can save the entire arguments array by using
Code:
echo $@ > $PathArgument/arguments.info
where $PathArgument is the Arg[] containing the path.
You can even save the only path if you know which argument is.
Suppose that the first argument is the Path, right?
Code:
echo $1 > $1/path.info
 
1 members found this post helpful.
Old 03-06-2012, 03:12 AM   #3
prravin1
Member
 
Registered: Feb 2012
Location: India
Posts: 43

Original Poster
Rep: Reputation: Disabled
Unhappy

Quote:
Originally Posted by Slackyman View Post
You can save the entire arguments array by using
Code:
echo $@ > $PathArgument/arguments.info
where $PathArgument is the Arg[] containing the path.
You can even save the only path if you know which argument is.
Suppose that the first argument is the Path, right?
Code:
echo $1 > $1/path.info
I forgot to mention that i take two arguments for the script. first argument is the input location and the second is the output location.

I need the complete path of argument two ie output in a text file. How can i do it?

Thanks...
 
Old 03-06-2012, 03:14 AM   #4
Slackyman
Member
 
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347

Rep: Reputation: 44
I think that saving the path into the pah is meaningless, anyway...
Code:
echo $2 > $2/path.info
and you'll have in path.info (text file) the path.
 
1 members found this post helpful.
Old 03-06-2012, 03:20 AM   #5
prravin1
Member
 
Registered: Feb 2012
Location: India
Posts: 43

Original Poster
Rep: Reputation: Disabled
Unhappy

Quote:
Originally Posted by Slackyman View Post
I think that saving the path into the pah is meaningless, anyway...
Code:
echo $2 > $2/path.info
and you'll have in path.info (text file) the path.
Ok. Now a second script need to read the path in path.info and then should enter in to it. How to go for it?
 
Old 03-06-2012, 03:29 AM   #6
Slackyman
Member
 
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347

Rep: Reputation: 44
I think it's better to save the file in a common well known location such as $HOME.
So, the first script will do:
Code:
echo $2 > $HOME/path.info
and the second will put the ouptup of path.info in a variable (let's say $script_path)
Code:
script_path=`cat $HOME/path.info`
or
Code:
script_path=$(cat $HOME/path.info)
Don't use the ~ (tilde) in scripts to indicate HOME path, but use $HOME since some shells mess with it.

Last edited by Slackyman; 03-06-2012 at 03:30 AM.
 
1 members found this post helpful.
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to enter generated output folders depending on time prravin1 Programming 7 02-29-2012 10:37 AM
Find a file path and directory path ak.lokesh Linux - Newbie 3 02-19-2009 12:37 PM
Could not find the gnomeConf.sh file that is generated by gnome-libs install alirezan1 Linux - Newbie 1 08-25-2006 02:56 PM
no output generated suchi_s Programming 2 09-08-2004 05:08 AM
Redhat 9: Where find errors generated from rc.local ? speedgelb Linux - General 4 01-30-2004 07:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration