[p4] Problem with redirecting stderr.
Olle Hallin
olle.hallin at gmail.com
Wed Sep 19 23:06:08 PDT 2007
A much simpler solution for this particular case (using the return code from
p4):
p4 login -s > /dev/null 2>&1
if [ $? == 0 ]; then echo "Logged in"; fi
It could even be simplified to
p4 login -s > /dev/null 2>&1 && echo "Logged in"
or
p4 login -s > /dev/null 2>&1 || echo "Not logged in"
Regards,
Olle
2007/9/19, Melissa Kacher <mkacher at msn.com>:
>
> Note the difference in redirection between the ones that worked and the
> ones
> that did not. 2>&1 vs. 2>1.
>
>
> ----Original Message Follows----
> From: "Steven W. Orr" <steveo at syslang.net>
> To: Perforce Users <perforce-user at perforce.com>
> Subject: [p4] Problem with redirecting stderr.
> Date: Wed, 19 Sep 2007 10:52:03 -0400 (EDT)
> MIME-Version: 1.0
> Received: from frankenrouter.perforce.com ([67.101.114.82]) by
> bay0-mc10-f14.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Wed,
> 19 Sep 2007 08:27:17 -0700
> Received: from p4tress.perforce.com (localhost [127.0.0.1])by
> frankenrouter.perforce.com (8.13.0.PreAlpha5/8.13.0.PreAlpha5) with ESMTP
> id
> l8JErQ6u037185;Wed, 19 Sep 2007 07:56:02 -0700 (PDT)
> Received: from computer.perforce.com (computer.perforce.com [10.0.0.197
> ])by
> frankenrouter.perforce.com (8.13.0.PreAlpha5/8.13.0.PreAlpha5) withESMTP
> id
> l8JEq5wp037181 for <_perforce-user at alameda0a.perforce.com>;Wed, 19 Sep
> 2007
> 07:52:06 -0700 (PDT)
> Received: from waypost.perforce.com ([10.199.0.13])by
> computer.perforce.com
> (8.12.11/8.12.8) with ESMTP id l8JEq5kI058142for
> <perforce-user at perforce.com>; Wed, 19 Sep 2007 07:52:05 -0700
> (PDT)(envelope-from steveo at syslang.net)
> Received: from saturn.syslang.net ([207.172.210.41])by
> waypost.perforce.com
> with ESMTP; 19 Sep 2007 07:52:05 -0700
> Received: from saturn.syslang.net (localhost.localdomain [127.0.0.1])by
> saturn.syslang.net (8.13.8/8.13.8) with ESMTP id l8JEq3HN017779for
> <perforce-user at perforce.com>; Wed, 19 Sep 2007 10:52:04 -0400
> Received: from localhost (steveo at localhost)by saturn.syslang.net
> (8.13.8/8.13.7/Submit) with ESMTP idl8JEq3V5017774for
> <perforce-user at perforce.com>; Wed, 19 Sep 2007 10:52:03 -0400
> X-Message-Delivery: Vj0zLjQuMDt1cz0wO2k9MDtsPTA7YT0w
> X-Message-Info:
>
> 6sSXyD95QpW39bbN056polws20lnsmgYdWJzZE4VHesw645B6bpKTkbxfeXkw+UMDXRQJ5jI97ohVlKC2Bh12Q==
> X-IronPort-Anti-Spam-Filtered: true
> X-IronPort-Anti-Spam-Result: AgAAAAnU8EbPrNIpk2dsb2JhbACOEgIBAQcEBgcg
> X-IronPort-AV: i="4.20,273,1186383600"; d="scan'208";
> a="4770912:sNHT32676650"
> Organization: SysLang
> X-BeenThere: perforce-user at perforce.com
> X-Mailman-Version: 2.1.6
> Precedence: list
> List-Id: Discuss Perforce with other users <perforce-user.perforce.com>
> List-Unsubscribe:
> <http://maillist.perforce.com/mailman/listinfo/perforce-user>,
> <mailto:perforce-user-request at perforce.com?subject=unsubscribe>
> List-Archive: <http://maillist.perforce.com/pipermail/perforce-user>
> List-Post: <mailto:perforce-user at perforce.com>
> List-Help: <mailto:perforce-user-request at perforce.com?subject=help>
> List-Subscribe:
> <http://maillist.perforce.com/mailman/listinfo/perforce-user>,
> <mailto:perforce-user-request at perforce.com?subject=subscribe>
> Errors-To: perforce-user-bounces at perforce.com
> Return-Path: perforce-user-bounces at perforce.com
> X-OriginalArrivalTime: 19 Sep 2007 15:27:18.0085 (UTC)
> FILETIME=[9062C750:01C7FAD1]
>
> In a shell script, I am testing to see if I am logged in. Please bear with
> me. Here are some lines from my console. I am *not* logged in to perforce
>
> 560 > p4 client -o > /tmp/p4mkdeb.21384 2>1
> 561 > cat /tmp/p4mkdeb.21384
> 562 > p4 client -o 2>&1 | cat > /tmp/p4mkdeb.21384
> 563 > cat /tmp/p4mkdeb.21384
> Your session has expired, please login again.
> 564 > rm /tmp/p4mkdeb.21384
> 565 > p4 client -o > /tmp/p4mkdeb.21384 2>1
> 566 > cat /tmp/p4mkdeb.21384
> 567 > p4 client -o
> Your session has expired, please login again.
> 568 > p4 client -o > xxx 2>&1
> 569 > cat xxx
> Your session has expired, please login again.
> 570 > rm /tmp/p4mkdeb.21384
> 571 > p4 client -o 2>&1 | cat > /tmp/p4mkdeb.21384
> 572 > cat /tmp/p4mkdeb.21384
> Your session has expired, please login again.
> 573 >
>
> On 560, I run client -o and on 561 I get an empty output file.
> On 562, I do the same thing but pass the output through a pipe and
> successfully catch the output.
> On 565, I do it again to prove to myself that I'm not nuts.
> On 567, I just sent it to the console so you can all see further that I'm
> not nuts.
> On 568, I change the output file to being in my local directory and now it
> works on 569.
>
> Server date: 2007/09/19 07:40:56 -0700 PDT
> Server version: P4D/LINUX24X86/2006.1/102189 (2006/06/27)
> Proxy version: P4P/LINUX26X86/2006.1/101890 (2006/06/21)
>
> If anyone can 'splain this one, I'd be fascinated to hear the answer.
>
> --
> Time flies like the wind. Fruit flies like a banana. Stranger things have
> .0.
> happened but none stranger than this. Does your driver's license say Organ
> ..0
> Donor?Black holes are where God divided by zero. Listen to me! We are all-
> 000
> individuals! What if this weren't a hypothetical question?
> steveo at syslang.net
> _______________________________________________
> perforce-user mailing list - perforce-user at perforce.com
> http://maillist.perforce.com/mailman/listinfo/perforce-user
>
> _______________________________________________
> perforce-user mailing list - perforce-user at perforce.com
> http://maillist.perforce.com/mailman/listinfo/perforce-user
>
--
Olle Hallin M.Sc.
+46 70 6653071
olle.hallin at hit.se
www.hit.se
More information about the perforce-user
mailing list