Sponsored Content
Top Forums Shell Programming and Scripting tsch, error setting a variable Post 302362882 by zivsegal on Sunday 18th of October 2009 11:44:20 AM
Old 10-18-2009
Thanks

It help me a lotSmilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Setting a variable

I want to set a variable to be any number of dashes. Rather than doing the following: MYVAR="------------------" I'd like to be able to set the variable to, say, 80 dashes but don't want to have to count 80 dashes. Is there a way to do this? (2 Replies)
Discussion started by: photh
2 Replies

2. UNIX for Dummies Questions & Answers

how to change sh to tsch UNIX

My oracle account uses tsch to use .cshrc. "Somehow" it was switch to sh and changed the login environment. My question is who has the right to change sh to tsch or other shells? How can I change back the original setting(tsch) from sh? This is what is appear in my /etc/passwd: ... (2 Replies)
Discussion started by: simt
2 Replies

3. Shell Programming and Scripting

Variable setting help please

L=0 cat test.sh | while read line do L='expr $1 + 1' echo $L done echo $l >>> the echo $L at the end produces 0 but i actually want it to produce the number of lines - any idea why this is happening? (16 Replies)
Discussion started by: penfold
16 Replies

4. Shell Programming and Scripting

Setting variable

How do you set a varible with information that contains a string and also another variable? For example: subject="Attention: $name / This $type needs your attention" The $xxxx are of course other variables that I instantiated earlier. Is it like Java where you have to use double quotes and... (1 Reply)
Discussion started by: briskbaby
1 Replies

5. UNIX for Dummies Questions & Answers

setting a variable

In my script, I have the following command.... du -sk `ls -ltd sales12|awk '{print $11}'`|awk '{print $1}' it returns the value 383283 I want to modify my script to capture that value into a variable. So, I try doing the following... var1=`du -sk `ls -ltd sales12|awk '{print... (5 Replies)
Discussion started by: tumblez
5 Replies

6. Shell Programming and Scripting

Help with setting a variable!

I am working within a while loop and i am trying to set a variable that will read out each count of the files. the problem is the count variable i have set up gives me a total and not the individual count of each file. in the data area there is 4 abc.dat and 1 def.dat. how can i do this??? ... (2 Replies)
Discussion started by: Pablo_beezo
2 Replies

7. UNIX for Dummies Questions & Answers

Why isn't this working? tsch-doit file

#! /usr/tsch foreach f (`cat contacts.list`) awk '{printf ($2 in a) ? ","$5 : (NR>1) ? RS $2 FS $5 : $2 FS $5; a} END{print e}' $f > $f_inter.map end My file: cat contacts.list is just a list of files. I get this error: doit_contacts2intermap.sh: Command not found. Thanks! (1 Reply)
Discussion started by: lost
1 Replies

8. Shell Programming and Scripting

Error in setting PATH variable in bash shell

Hi, I am new to shell scripting.I tried adding an entry to the path variable like below export PATH=$PATH:/opt/xxx/bin But am getting an error invalid identifier /opt/xxx/bin Can someone tell me the error above and correct me . Thanks and Regards, Padmini (2 Replies)
Discussion started by: padmisri
2 Replies

9. Shell Programming and Scripting

Error in tsch shell scripting..

Hi Everyone, I am using gdb-7.5 to connect to the target. When I gave the./configure --target=xyz --build=i686-pc-mingw32 --host=i686-pc-mingw32 command then checking build system type... i686-pc-mingw32 checking host system type... i686-pc-mingw32 checking target system type... xyz-mingw32... (3 Replies)
Discussion started by: Heeka
3 Replies

10. Homework & Coursework Questions

Getting a command not found when comparing in tsch

Hey everyone, I am almost done with this assignment I have to do but there is one last thing nagging me that I can't seem to find. In my script I am feeding line by line to a ./test file and I am getting the return answer correctly. The goal is to test the current script (check.sh) and if it's... (1 Reply)
Discussion started by: tastybrownies
1 Replies
Net::Ifconfig::Wrapper(3pm)				User Contributed Perl Documentation			       Net::Ifconfig::Wrapper(3pm)

NAME
Net::Ifconfig::Wrapper - provides a unified way to configure network interfaces on FreeBSD, OpenBSD, Solaris, Linux, OS X, and WinNT (from Win2K). Version 0.11 SYNOPSIS
#!/usr/local/bin/perl -w # uni-ifconfig.pl # The unified ifconfig command. # Works the same way on FreeBSD, OpenBSD, Solaris, Linux, OS X, WinNT (from Win2K). # Note: due of Net::Ifconfig::Wrapper limitations 'inet' and 'down' commands # are not working on WinNT. +/-alias are working, of course. use strict; use Net::Ifconfig::Wrapper; my $Usage = << 'EndOfText'; uni-ifconfig.pl # Print this notice uni-ifconfig.pl -a # Print info about all interfaces uni-ifconfig.pl <iface> # Print info obout specified interface uni-ifconfig.pl <iface> down # Bring specified interface down uni-ifconfig.pl <iface> inet <AAA.AAA.AAA.AAA> mask <MMM.MMM.MMM.MMM> # Set the specified address on the specified interface # and bring this interface up uni-ifconfig.pl <iface> inet <AAA.AAA.AAA.AAA> mask <MMM.MMM.MMM.MMM> [+]alias # Set the specified alias address # on the specified interface uni-ifconfig.pl <iface> inet <AAA.AAA.AAA.AAA> [mask <MMM.MMM.MMM.MMM>] -alias # Remove specified alias address # from the specified interface EndOfText my $Info = Net::Ifconfig::Wrapper::Ifconfig('list', '', '', '') or die $@; scalar(keys(%{$Info})) or die "No one interface found. Something wrong? "; if (!scalar(@ARGV)) { print $Usage; exit 0; } if ($ARGV[0] eq '-a') { defined($ARGV[1]) and die $Usage; foreach (sort(keys(%{$Info}))) { print IfaceInfo($Info, $_); }; exit 0; }; $Info->{$ARGV[0]} or die "Interface '$ARGV[0]' is unknown "; if (!defined($ARGV[1])) { print IfaceInfo($Info, $ARGV[0]); exit 0; } my $CmdLine = join(' ', @ARGV); my $Result = undef; if ($CmdLine =~ m/As*([w{}-]+)s+downs*/i) { $Result = Net::Ifconfig::Wrapper::Ifconfig('down', $1, '', ''); } elsif ($CmdLine =~ m/As*([w{}-]+)s+inets+(d{1,3}(?:.d{1,3}){3})s+masks+(d{1,3}(?:.d{1,3}){3})s*/i) { $Result = Net::Ifconfig::Wrapper::Ifconfig('inet', $1, $2, $3); } elsif ($CmdLine =~ m/As*([w{}-]+)s+inets+(d{1,3}(?:.d{1,3}){3})s+masks+(d{1,3}(?:.d{1,3}){3})s++?aliass*/i) { $Result = Net::Ifconfig::Wrapper::Ifconfig('+alias', $1, $2, $3); } elsif ($CmdLine =~ m/As*([w{}-]+)s+inets+(d{1,3}(?:.d{1,3}){3})s+(:?masks+(d{1,3}(?:.d{1,3}){3})s+)?-aliass*/i) { $Result = Net::Ifconfig::Wrapper::Ifconfig('-alias', $1, $2, ''); } else { die $Usage; }; $Result or die $@; exit 0; sub IfaceInfo { my ($Info, $Iface) = @_; my $Res = "$Iface: ".($Info->{$Iface}{'status'} ? 'UP' : 'DOWN')." "; while (my ($Addr, $Mask) = each(%{$Info->{$Iface}{'inet'}})) { $Res .= sprintf(" inet %-15s mask $Mask ", $Addr); }; $Info->{$Iface}{'ether'} and $Res .= " ether ".$Info->{$Iface}{'ether'}." "; $Info->{$Iface}{'descr'} and $Res .= " descr '".$Info->{$Iface}{'descr'}."' "; return $Res; }; DESCRIPTION
This module provides a unified way to configure the network interfaces on FreeBSD, OpenBSD, Solaris, Linux, OS X, and WinNT (from Win2K) systems. Only "inet" (IPv4) and "ether" (MAC) addresses are supported at the moment On Unixes this module calls the system "ifconfig" command to perform the actions. On Windows the functions from IpHlpAPI.DLL are called. For all supported Unixes "Net::Ifconfig::Wrapper" expect "ifconfig" command to be "/sbin/ifconfig". Module was tested on FreeBSD 4.7,4.8,5.3 (Intel), RedHat 6.2,7.3,8.0 (Intel), Win2000 Pro (Intel), OpenBSD 3.1 (SPARC), Solaris 7 (SPARC), OS X 10.3 (aka Panther), OS X 10.4 (aka Tiger). In MSWin32 family only WinNT is supported. In WinNT family only Win2K or later is supported. The Net::Ifconfig::Wrapper methods "Ifconfig(Command, Interface, Address, Netmask);" The first and the last method of the "Net::Ifconfig::Wrapper" module. Do all the job. The particular action is described by the $Command parameter. $Command could be: 'list' "Ifconfig('list', '', '', '')" will return the reference to the hash contains the information about interfaces. The structure of this hash is the following: {IfaceName => {'status' => 0|1 # The status of the interface. 0 means down, 1 means up 'ether' => MACaddr, # The ethernet address of the interface if available 'descr' => Description, # The description of the interface if available 'inet' => {IPaddr1 => NetMask, # The IP address and his netmask, both are in AAA.BBB.CCC.DDD notation IPaddr2 => NetMask, ... }, ... }; Interface, Address, Netmask parameters are ignored. The following programs are called: FreeBSD "/sbin/ifconfig -a" Solaris "/sbin/ifconfig -a" OpenBSD "/sbin/ifconfig -A" Linux "/sbin/ifconfig -a" OS X "/sbin/ifconfig -a" MSWin32 "GetAdaptersInfo" function from "IpHlpAPI.DLL" Limitations: OpenBSD: "/sbin/ifconfig -A" command is not returning information about MAC addresses so we are trying to get it from '/usr/sbin/arp -a' command (first 'static' entry). If no one present the 'ff:ff:ff:ff:ff' address is returned. MSWin32: "GetAdaptersInfo" function is not returning information about interface which have address 127.0.0.1 binded so "Net::Ifconfig::Wrapper" have no ability to display it. Not limitation but little problem: MSWin32 interface names are not human-readable, they looks like "{843C2077-30EC-4C56-A401-658BB1E42BC7}" (on Win2K at least). 'inet' This function is used to set IPv4 address on interface. It have to be called as Ifconfig('inet', $IfaceName, $Addr, $Mask); $IfaceName is an interface name as displayed by 'list' command $Addr is an IPv4 address in the "AAA.AAA.AAA.AAA" notation $Mask is an IPv4 subnet mask in the "MMM.MMM.MMM.MMM" notation The following actual "ifconfig" programs are called FreeBSD "/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up" Solaris "/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up" OpenBSD "/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up" Linux "/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up" OS X "/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up" MSWin32: nothing :( Limitations: MSWin32: I did not find the relaible way to recognize the "main" address on the Win32 network interface, so I have disabled this functionality. If you know the way please let me know. 'up' Just a synonym for 'inet' 'down' This function is used to bring specified interface down. It have to be called as Ifconfig('inet', $IfaceName, '', ''); $IfaceName is an interface name as displayed by 'list' command Address and Netmask are ignored. The following actual "ifconfig" programs are called FreeBSD "/sbin/ifconfig %Iface% down" Solaris "/sbin/ifconfig %Iface% down" OpenBSD "/sbin/ifconfig %Iface% down" Linux "/sbin/ifconfig %Iface% down" OS X "/sbin/ifconfig %Iface% down" MSWin32 nothing :( Limitations: MSWin32: I did not find the way to implement the 'up' command so I did not implement 'down'. '+alias' This function is used to set IPv4 alias address on interface. It have to be called as Ifconfig('+alias', $IfaceName, $Addr, $Mask); $IfaceName is an interface name as displayed by 'list' command $Addr is an IPv4 address in the "AAA.AAA.AAA.AAA" notation $Mask is an IPv4 subnet mask in the "MMM.MMM.MMM.MMM" notation The following actual "ifconfig" programs are called FreeBSD "/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% alias" Solaris "/sbin/ifconfig %Iface%:%Logic% inet %Addr% netmask %Mask% up" OpenBSD "/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% alias" Linux "/sbin/ifconfig %Iface%:%Logic% inet %Addr% netmask %Mask% up" OS X "/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% alias" MSWin32 "AddIPAddress" function from "IpHlpAPI.DLL" First available logic interface is taken automatically for Solaris and Linux 'alias' Just a synonim for '+alias' '-alias' This function is used to remove IPv4 alias address from interface. It have to be called as Ifconfig('-alias', $IfaceName, $Addr, ''); $IfaceName is an interface name as displayed by 'list' command $Addr is an IPv4 address in the "AAA.AAA.AAA.AAA" notation Netmask> parameter is ignored The following actual "ifconfig" programs are called FreeBSD "/sbin/ifconfig %Iface% inet %Addr% -alias" Solaris "/sbin/ifconfig %Iface%:%Logic% down" OpenBSD "/sbin/ifconfig %Iface% inet %Addr% -alias" Linux "/sbin/ifconfig %Iface%:%Logic% down" OS X "/sbin/ifconfig %Iface% inet %Addr% -alias" MSWin32 "DeleteIPAddress" function from "IpHlpAPI.DLL" Appropriate logic interface is obtained automatically for Solaris and Linux On success "Ifconfig(...)" returns the defined value. Actually, it is a reference to the array contains the output of the actual "ifconfig" program called. In case of troubles "Ifconfig(...)" returns 'undef' value, $@ variable contains the error message. EXPORT None by default. AUTHOR
Daniel Podolsky, <tpaba@cpan.org> SEE ALSO
ifconfig(8), Internet Protocol Helper in Platform SDK. perl v5.14.2 2012-01-19 Net::Ifconfig::Wrapper(3pm)
All times are GMT -4. The time now is 08:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy