niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » shell
Passing parameters back from a function
Post new topic   Reply to topic Page 41 of 43 [637 Posts] View previous topic :: View next topic
Goto page:  Previous  1, 2, 3, ..., 39, 40, 41, 42, 43 Next
Author Message
Janis Papanagnou
*nix forums Guru


Joined: 24 Feb 2005
Posts: 450

PostPosted: Sat Apr 01, 2006 5:36 pm    Post subject: Re: some problem about unix cmd "export" Reply with quote

geniusbear1016@gmail.com wrote:
Quote:
Thanks for your relpy, Janis.

I know the way that use dot.
But I wnna understand the cmd export clearly.

From the ksh88 man page...
:
: export [ name[ =value ] ] . . .
:
: The given names are marked for automatic export to the environment
: of subsequently-executed commands.

Quote:
Can you give me an easy example that use export in shell correctly?

export var="string value"

export var2=$var

var3=$var
export var3


Janis

Quote:
Kunio
Back to top
lancerset@gmail.com
*nix forums beginner


Joined: 21 Mar 2006
Posts: 29

PostPosted: Sat Apr 01, 2006 11:07 pm    Post subject: Re: cuts fields by date sed, awk ? Reply with quote

Hello Again,

Do you know why when date is variablized it doesnt get
interpolated..Although the
date written as /Apr 01/ works just fine...

DATE=`date +%b\ %d`
perl -00ne 'print if /$DATE/' Log01.log > "$DATE".Log.log

I've tried your method as well with $ENV, and nothing is getting
written to the log
Back to top
Chris F.A. Johnson
*nix forums Guru


Joined: 20 Feb 2005
Posts: 2268

PostPosted: Sat Apr 01, 2006 11:19 pm    Post subject: Re: cuts fields by date sed, awk ? Reply with quote

On 2006-04-01, onlineviewer wrote:
Quote:
Hello Again,

Do you know why when date is variablized it doesnt get
interpolated..Although the
date written as /Apr 01/ works just fine...

DATE=`date +%b\ %d`
perl -00ne 'print if /$DATE/' Log01.log > "$DATE".Log.log

Variables are not expanded when used inside single quotes. Use
double quotes instead:

perl -00ne "print if /$DATE/" Log01.log > "$DATE".Log.log

Quote:
I've tried your method

Whose method? Please read <http://cfaj.freeshell.org/google>.

Quote:
as well with $ENV, and nothing is getting
written to the log

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Back to top
xicheng@gmail.com
*nix forums Guru


Joined: 10 Nov 2005
Posts: 468

PostPosted: Sun Apr 02, 2006 12:47 am    Post subject: Re: cuts fields by date sed, awk ? Reply with quote

onlineviewer wrote:
Quote:
Hello Again,

Do you know why when date is variablized it doesnt get
interpolated..Although the
date written as /Apr 01/ works just fine...

DATE=`date +%b\ %d`
perl -00ne 'print if /$DATE/' Log01.log > "$DATE".Log.log

I've tried your method as well with $ENV, and nothing is getting
written to the log

because you use the hash %ENV of perl which needs your variable set in
your program's enviroment. so you can either add

export DATE

before you run perl command, or you can just prefix your definition to
the perl command, like:

VAR="something" perl -e '#perl cmd'

this influences only the enviromental parameters of your current
program "perl" instead of your shell enviroment..

so you can do:
either:
export DATE=`date +%b\ %d`
perl -00ne 'print if /$ENV{DATE}/' Log01.log > "$DATE".Log.log

or in one line:
DATE=`date +%b\ %d` perl -00ne 'print if /$ENV{DATE}/' Log01.log >
"${DATE}.Log.log"

Xicheng
Back to top
Janis Papanagnou
*nix forums Guru


Joined: 24 Feb 2005
Posts: 450

PostPosted: Sun Apr 02, 2006 4:15 am    Post subject: Re: fill a (cd|dvd) up efficently Reply with quote

TOC wrote:
Quote:
back in the old (dos) days, I used to have a utility which would, given a
group of files to backup, would efficiently fill up a floppy disk.

I would like to put together something similar in bash for burning blank
single sided data DVDs.

so basically say I have a couple hundred files ranging from 10MB to 1000MB.

I would like to do something like the following:


./_find_files_that_will_fit_efficiantly_on_a_dvd.sh .


#the following files occupy 4.61 GB of disk space
#+and should fit on a single sided data dvd.


/home/myname/data/file234234.dat
/home/myname/data/file2342345344.dat
/home/myname/data/file234345234.dat
/home/myname/data/file2233454534234.dat
/home/myname/data/file2342534234.dat
/home/myname/data/file2342543234.dat


hope that makes sense... I will monitor this thread closely... so if I am
unclear, feel free to ask me questions.


thanks in advance.


For the background look for "Greedy Algorithm"

"Martello and Toth (1990) proposed a greedy version of the algorithm
to solve the knapsack problem. Their version sorts the essentials in
decreasing order and then proceeds to insert them into the sack,
starting from the first element (the greatest) until there is no
longer space in the sack for more. If k is the maximum possible number
of essentials that can fit into the sack, the greedy algorithm is
guaranteed to insert at least k/2 of them." [quoted from Wikipedia]

Which is the base of the solutions suggested upthread.

See also: http://en.wikipedia.org/wiki/Greedy_algorithm

Janis
Back to top
Michael Paoli
*nix forums Guru Wannabe


Joined: 10 Oct 2005
Posts: 107

PostPosted: Sun Apr 02, 2006 8:02 am    Post subject: Re: some problem about unix cmd "export" Reply with quote

geniusbear1016@gmail.com wrote:
Quote:
I can use the cmd export well.
ex:export abc=100
and i can use set or export to see the variable abc
abc=100
but when i write it in a shell.
ex: shell tt, chmod 777 tt
content of tt: export abc=100
execute: tt
and i can't see the variable abc when i type set or export cmd.
Can anyone tell me why ?
or give me some ref..

Pretty much the same question was addressed rather recently.
See this thread:
http://groups.google.com/group/comp.unix.admin/browse_thread/thread/d47258249c90484e/063fd19260bf2ebf?&hl=en
Or this article in that thread:
Message-ID: <1142520175.663132.94860@z34g2000cwc.googlegroups.com>

Also, chmod 777 is generally a very bad idea security-wise.
Back to top
Mitch Johnston
*nix forums beginner


Joined: 05 Feb 2006
Posts: 10

PostPosted: Sun Apr 02, 2006 8:36 am    Post subject: Re: Backspace and Delete key mappings Reply with quote

On Fri, 31 Mar 2006 15:39:01 -0500, <dmarkh@cfl.rr.com> wrote:

Quote:
I have read much on the subject of these 2 keys. Yet I have not been
able to do what I need to do. I need the backspace key to generate
0x08(^H) and the delete key to generate 0x7f(del) during the execution
of a single application. On all my linux boxes the backspace generates
0x7f(^?) and the del key generates ^[[3~. I need to be able to change
that before I execute my program then change it back when my
application is done. stty does NOT do the job nor does my application
use termdef. I have found a little expect script that does do what I
need. I execute "script program" and the keys come out like I want.

#!/usr/bin/expect

eval spawn -noecho $argv

interact {
\177 {send "\010"}
"\033\[3~" {send "\177"}

However I am really looking for basic Linux commands that can be
executed from the bash shell that will do the same thing or a method of
making my application do it from within its self.

Thanks and regards
Mark


You can use 'stty' to set it:

stty erase {key}

..\\itch - Pain - finally, something we can depend on.

--
..\\itch Johnston - Bearded Dragon
Back to top
dmarkh@cfl.rr.com
*nix forums beginner


Joined: 02 Apr 2006
Posts: 1

PostPosted: Sun Apr 02, 2006 8:43 am    Post subject: Re: Backspace and Delete key mappings Reply with quote

As I noted in the post, stty does not do it.
Back to top
Casper H.S. Dik
*nix forums Guru


Joined: 20 Feb 2005
Posts: 1634

PostPosted: Sun Apr 02, 2006 11:55 am    Post subject: Re: Backspace and Delete key mappings Reply with quote

"Mitch Johnston" <mxj_97@yahoo.com> writes:

Quote:
You can use 'stty' to set it:

stty erase {key}

An unfortunate shortcoming of the way UNIX handles ttys is that
you can only have one "erase" key; I'd prefer both backspace and delete
to erase; while most shells do this, other programs do not.

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Back to top
Harry
*nix forums addict


Joined: 17 Mar 2005
Posts: 58

PostPosted: Sun Apr 02, 2006 11:06 pm    Post subject: Re: fill a (cd|dvd) up efficently Reply with quote

TOC wrote...
Quote:

back in the old (dos) days, I used to have a utility which would, given a
group of files to backup, would efficiently fill up a floppy disk.

I would like to put together something similar in bash for burning blank
single sided data DVDs.

Python:

http://www.idt.mdh.se/kpt/Homepage/source/binpack

Perl:

http://www.cpan.org/modules/by-module/Algorithm/Algorithm-BinPack-0.5.tar.gz
Back to top
lancerset@gmail.com
*nix forums beginner


Joined: 21 Mar 2006
Posts: 29

PostPosted: Mon Apr 03, 2006 3:15 am    Post subject: Re: cuts fields by date sed, awk ? Reply with quote

thats great,,thanks a bunch
Back to top
BusyBoy
*nix forums beginner


Joined: 27 May 2005
Posts: 44

PostPosted: Thu Apr 06, 2006 7:44 am    Post subject: Re: 分享還不錯用的免費電子書閱讀器"eREAD" Reply with quote

really?


Moody
PTML
Back to top
TeraNews
*nix forums beginner


Joined: 08 Apr 2006
Posts: 1

PostPosted: Sat Apr 08, 2006 12:20 am    Post subject: Re: rsh without password, New problem Reply with quote

"sunny" <sunny.ijk@gmail.com> wrote in message
news:1144432795.497672.227460@j33g2000cwa.googlegroups.com...
Quote:




Hi all,
Thanks all for having this group.
I am New to the world of Linux and networking. I request you
to help me in solving my problem.

I have 2 linux installed machines. Machine A and Machine B.
Basically i need to execute "rsh B -l root mkdir /root/sanny" command
from machine A.
And i need to use rsh only.

Senario 1:: I am able to connect succesfully from Machine A to Machine
B with { #rsh A } which asks for password. But when i issues a command
along with it it gives me an error. i.e when { #rsh A -l root date} i
get error as "poll:protocol failure in circuit setup".
Senario 2:: I am not able to login without command execution. i.e i am
not able to connect to the Machine A from Machine B with {#rsh B}
itself. It says "A.domain.com:Connect refused"

The below the following steps that i followed on these 2 machines.
1) Both machines have ALL : ALL in /etc/hosts.allow file and nothing in
/etc/hosts.deny file.
2) Both machines have rsh , rlogin, rexec enabled i.e in the file
/etc/xinetd.d/(rsh) (rlogin) (rexec) the disable is turned on from
disable=yes to disable=no.
3)Both the machines have ~/.rhosts file conents as "+ +" . (i also
tried with host.domain.com names).
4)Both the machines had /etc/hosts.equiv files with B.domain.com and
A.domain.com names respectively in Machine A and in Machine B
5)Both the machines were restarted after saving the changes.

Thanks in advance
Sanny




OK try this...Coming from he Solaris world and NIS, I did exactly as you
did.

What I found is that although putting a simple "+" in the .rhosts file
should work,
it didn't for me. What I did is experiment with the /etc/hosts.equiv file
and put a "+" in
there as well.

Then I explicity put the host name in there. Voila...It worked.

So, not really caring about security, I created a netgroup rh50 (,,) and
stuck that
in the hosts.equiv as such +@rh50

That worked. Play around a bit and see.

Good Luck
Back to top
miles.purdy@shaw.ca
*nix forums beginner


Joined: 15 Mar 2006
Posts: 39

PostPosted: Mon Apr 10, 2006 5:51 pm    Post subject: Re: rsh without password, New problem Reply with quote

Did you get this to work yet?

Under AIX, which sounds very similar:

1. configure inetd
2. configure TCP Wrapper:

root@unxd1:/home/aclient>cat /etc/hosts.allow
#
rshd: ALL@10.113.209.0/255.255.255.0

I really wouldn't use ALL: ALL in hosts.allow unless that is what you
want, but then why use TCP Wrapper?

root@unxd1:/home/aclient>cat /etc/hosts.deny
ftpd: ALL: (/usr/sbin/safe_finger -l @%h | /usr/bin/mail -s %d-%c
root) &
rexecd: ALL
rshd: ALL
rlogind: ALL
telnetd: ALL

In /.rhosts, put the name that can be looked up, this is important.
Make sure that A and B are in /etc/hosts or your DNS server. In
~/.rhosts just put B (on A) and A on B. Like this:
A +
B +

Again verify that your name resolution works.
Restart inetd.

I don't use NIS and /etc/hosts.equiv.
Back to top
Uri Guttman
*nix forums Guru Wannabe


Joined: 22 Jan 2006
Posts: 253

PostPosted: Thu May 04, 2006 6:42 pm    Post subject: Re: Script that gives instance count unique patterns in a sorted file Reply with quote

Quote:
"GUA" == Generic Usenet Account <usenet@sta.samsung.com> writes:

that is some of the worst perl code i have ever seen. it won't even
compile. come back when your code compiles cleanly.

uri

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 41 of 43 [637 Posts] Goto page:  Previous  1, 2, 3, ..., 39, 40, 41, 42, 43 Next
View previous topic :: View next topic
The time now is Tue Dec 02, 2008 6:36 am | All times are GMT
navigation Forum index » Programming » shell
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Function Pointer Sikandar C 3 Fri Jul 21, 2006 1:23 pm
No new posts Shortening URLs passing through a squid hierarchy Irvine, Doug - Resources Squid 0 Fri Jul 21, 2006 10:15 am
No new posts Arbitrary function with parameter darknails@gmail.com C++ 2 Fri Jul 21, 2006 9:58 am
No new posts mod_rewrite to go from http to https and back sevans@bigskypenguin.com Apache 0 Fri Jul 21, 2006 5:12 am
No new posts Is there C/C++ corresponding function in Linux for Java's... xiebopublic@gmail.com apps 4 Fri Jul 21, 2006 3:22 am

Myspace Backgrounds | Free Advertising | Mortgages | Loans | Debt Consolidation
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 2.9268s ][ Queries: 16 (2.8029s) ][ GZIP on - Debug on ]