LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 06-26-2003, 03:46 PM   #1
Linh
Member
 
Registered: Apr 2003
Posts: 178

Rep: Reputation: 30
Bash script


1) #!/bin/bash -p
What is -p means ?

2) killall dhcpcd > dev/null 2 > & 1
What is 2 > & 1 means ?

3) if [ $? -ne 0 ]
then
ifconfig eth0 up;
exit 1;
fi
What is "$?" ? Does it refer to the last variable reference ?

4) suid putdata update &&
What is && means ?

I did look at the web site that gives instruction on BASH programming, but some of the things mentioned above was not covered.
 
Old 06-26-2003, 04:24 PM   #2
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
1.) dunno. try man bash

2.)
2 refers to 'stderr'
> is redirection
1 is 'stdin'
& (in this context) is like addressof or whereabouts.
so this says: redirect stderr to where ever the hell stdin is headed. In this case both stdin and stderr are going to /dev/null so you'll never see any output

3.) I forget. again, man bash

4.) && is logical 'and'. I don't see what it'll do here, but it's like ./configure && make (configure and make, but don't make if configure fails).

all of these are answered in man bash. please check it out.
 
Old 06-26-2003, 04:26 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
1) As far as I can make out from "man bash", -p stops bash reading a users startup files
2) 2>&1 means ouput the error stream to the standard output (the standard output is then ouptu to the file as has been specified)
3) $? contains the exit status of the last command
4) && means that the command will wait to be completed before continuing.
 
Old 06-26-2003, 04:38 PM   #4
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
Quote:
Originally posted by david_ross
4) && means that the command will wait to be completed before continuing.
Just to be pendantic. . . && means will wait for SUCCESSFULL completion before continuing (i.e. exit status of 0). ;; means will wait for completion before continuing (any exit status).
 
  


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
Bash script Linh Programming 4 04-21-2004 05:19 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script brian0918 Programming 7 06-12-2003 06:06 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM

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

All times are GMT -5. The time now is 08:09 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