Igor Delovski Board Forum Index Igor Delovski Board
My Own Personal Slashdot!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Terminal & Shell Scripting

 
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> General Programming
General Programming  
Author Message
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Mon Oct 09, 2006 10:08 pm    Post subject: Terminal & Shell Scripting Reply with quote

Apple Developer Connection: Mac OS X Shell Scripting

"Shell scripts are a fundamental part of the Mac OS X programming
environment. As a ubiquitous feature of UNIX-based, Linux, and UNIX-like
operating systems, they represent a way of writing certain types of
command-line tools in a way that works on a fairly broad spectrum of
computing platforms."
Back to top
View user's profile Send private message
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Sun Oct 22, 2006 10:49 pm    Post subject: Reply with quote

Digg: Automate windows tasks with this simple scripting language

"AutoIt v3 is a freeware BASIC-like scripting language designed for
automating the Windows GUI and general scripting. It uses a combination
of simulated keystrokes, mouse movement and window/control
manipulation in order to automate tasks in a way not possible or reliable
with other languages."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Mar 17, 2007 1:16 am    Post subject: Reply with quote

JoS: Learning Shell Scripting

"I would like to learn how to write UNIX shell scripts, but I would like to do
so under some sort of emulator under Windows. I currently have Cygwin but
cannot get it to run my 'hello world' script. Does it execute shell scripts? If so,
how?"
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Tue May 08, 2007 12:45 am    Post subject: Reply with quote

Digg: Introduction to Open Source Scripting on Mac OS X

"If you're new to the world of open source scripting languages —or just want
to brush up on what's unique about Mac OS X—this article will help you get
oriented. Mac OS X bundles the most popular scripting languages out of the
box: perl, Python, php, tcl, Ruby—not to mention shells such as bash, ksh,
zsh, and csh."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Wed May 16, 2007 9:19 pm    Post subject: Reply with quote

dartmouth.edu - Macintosh Scripting Systems

"Discussion of the various scripting systems for Apple Macintosh computers
including Userland's Frontier, Apple's AppleScript, and any others. Users
are encouraged to share any technical information and interesting scripts they
have and post technical questions. Postings from America Online CompuServe,
and AppleLink will be gatewayed to this list. This list is unmoderated."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Feb 16, 2008 1:41 am    Post subject: Reply with quote

uf - How can I start ./app in the current directory when make did ok?

"Gedit has the Ctrl+f8 shortcut to automatically invoke make. I added
another command "Build and run", which performs the same as "Build",
but at the end when make finishes successful, tries to start ./app. How
would look the code for that?"
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Tue Feb 19, 2008 8:21 pm    Post subject: Reply with quote

reddit - Bash users: What do you have for your $PS1?

"Mine's horribly complicated and includes..."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat May 31, 2008 8:09 pm    Post subject: Reply with quote

Beginning SSH on Ubuntu

"SSH is a powerful tool which allows secure remote login over insecure net-
works. It provides an encrypted terminal session with strong authentication
of both the server and client using public-key cryptography. This tutorial will
cover the basics of SSH’s most useful features..."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Thu Mar 05, 2009 4:23 pm    Post subject: Reply with quote

CW - The A-Z of Programming Languages: Bourne shell, or sh

"An in-depth interview with Steve Bourne, creator of the Bourne shell, or sh.

Through this work, and a series of connections and circumstance, Bourne got
to know people at Bell Labs who then offered him a job in the Unix group in
1975. It was during this time Bourne developed sh."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Mar 21, 2009 11:36 pm    Post subject: Reply with quote

Command-Line-Fu

"Command-Line-Fu is the place to record those command-line gems that
you return to again and again. All commands can be commented on and
discussed - digg-esque voting is also encouraged so the best float to the
top."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sun Apr 04, 2010 10:52 pm    Post subject: Reply with quote

MF - Bash script to zip multiple directories?

"I need to put together a bash script that will read in a text file containing a
list of directories (one per line) and for each line output a separate archive."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Fri Jul 16, 2010 4:25 pm    Post subject: Reply with quote

cyberciti.biz - Howto: Linux Rename Multiple Files At a Shell Prompt

"Rename command syntax

rename oldname newname *.files
For example rename all *.bak file as *.txt, enter:
$ rename .bak .txt *.bak

Renaming multiple files at a shell prompt is always considered as a black art
by many UNIX gurus."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Thu Nov 13, 2014 12:14 am    Post subject: Reply with quote

macgasm.net - Good Morning, Your Mac Keeps A Log Of All Your Downloads

"According to OS X Daily the Launch Services quarantine keeps a list of
every file you’ve ever downloaded on your Mac, as that’s what triggers
the warning dialog about opening files from the Internet."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Feb 18, 2017 11:09 am    Post subject: Reply with quote

github - Awesome OSX Command Line

"A curated list of shell commands and tools specific to OS X.

'You don't have to know everything. You simply need to know where to find
it when necessary.' (John Brunner)"
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Fri Jun 30, 2017 10:06 am    Post subject: Reply with quote

so - How to check if a variable is set in Bash?

Here's how to test whether a parameter is unset, or empty ("Null") or set with a value:

Code:
+--------------------+----------------------+-----------------+-----------------+
|                    |       parameter      |     parameter   |    parameter    |
|                    |   Set and Not Null   |   Set But Null  |      Unset      |
+--------------------+----------------------+-----------------+-----------------+
| ${parameter:-word} | substitute parameter | substitute word | substitute word |
| ${parameter-word}  | substitute parameter | substitute null | substitute word |
| ${parameter:=word} | substitute parameter | assign word     | assign word     |
| ${parameter=word}  | substitute parameter | substitute null | assign word     |
| ${parameter:?word} | substitute parameter | error, exit     | error, exit     |
| ${parameter?word}  | substitute parameter | substitute null | error, exit     |
| ${parameter:+word} | substitute word      | substitute null | substitute null |
| ${parameter+word}  | substitute word      | substitute word | substitute null |
+--------------------+----------------------+-----------------+-----------------+

Source: POSIX: Parameter Expansion.
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Fri Jun 30, 2017 1:06 pm    Post subject: Reply with quote

grymoire.com - Sh - the Bourne Shell

"Bourne Shell, and filename expansion
Shell Concepts
Verifying which shell you are running
Shell basics
Meta-characters and Filename expansion
Finding the executable
Quoting with the Bourne Shell
Nested quotations
Strong versus weak quoting
Quoting over several lines
Mixing quotation marks
Quotes within quotes - take two
Placing variables within strings
Variables
A subtle point
The set command
Environment Variables
Special Environment Variables
PATH - Sets searchpath
HOME - Your home directory
CDPATH - cd searchpath
IFS - Internal Field Seperator
PS1 - Normal Prompt
PS2 - Secondary Prompt
MAIL - Incoming mail
MAILCHECK - How often to check for mail
SHACCT - Accounting file
MAILPATH - searchpath for mail folders
Bourne Shell Variables - Alternate Formats
Using quoting and shell variables
Using curly braces with variables
${variable?value} - Complain if undefined
${variable-default} - Use default if undefined
${variable+value} - Change if defined
${variable=value} - Redefine if undefined
Undefining Variables
${x:-y}, ${x:=y}, ${x:?y}, ${x:+y} forms
Order of evaluation
Special Variables in the Bourne Shell
Positional Parameters $1, $2, ..., $9
$0 - Scriptname
$* - All positional parameters
$@ - All positional parameters with spaces
$# - Number of parameters
$$ - Current process ID
$! - ID of Background job
$? - error status
$- Set variables
Options and debugging
Special options
X - Bourne Shell echo flag
V - Bourne Shell verbose flag
Combining flags
U - unset variables
N - Bourne Shell non-execute flag
E - Bourne Shell exit flag
T - Bourne Shell test one command flag
A - Bourne Shell mark for export flag
K - Bourne Shell keyword flag
H - Bourne Shell hash functions flag
The $- variable
- - Bourne Shell hyphen option
Other options
C - Bourne Shell command option
S - Bourne Shell shell-session option
I - Bourne Shell shell-interactive option
R - Bourne Shell restricted shell option
P - Bourne Shell privileged shell option
unset
Bourne Shell: Status, Pipes and branches
Unnecessary process execution
$@ versus ${1+$@}
Status and Wasted Processes
Simple Flow Control
Changing Precedence
Putting it all together
Bourne Shell Flow Control Commands: If, While and Until
Commands that must be first on the line
While - loop while true
Until - loop until true
Bourne Shell Flow Control Commands
For - Repeating while changing a variable
Case - Checking multiple cases
Break and continue
Expr - Bourne Shell Expression Evaluator
Arithmetic Operators
Relational Operators
Boolean Operators
The string operator
Precedence of the Operators
Berkeley Extensions
Bourne Shell -- Functions and argument checking
Passing values by name
Exiting from a function
Checking the number of arguments
UNIX conventions for command line arguments
Checking for optional arguments
Job Control"
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Fri Jul 14, 2017 7:31 pm    Post subject: Reply with quote

so - How do I monitor opened files of a process in realtime?

"You can also attach strace to a running process with the -p PID option."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Sep 09, 2017 10:03 pm    Post subject: Reply with quote

Thomas Keller - ACLs on Mac OS X

"The first thing to notice is that starting with Mac OS X 10.6 (Snow Leopard)
ACLs are always enabled and cannot be disabled as in earlier versions. All ACL
commands are baked into the chmod command and parsed from a string you
give it with the '+a' option."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Wed Sep 20, 2017 10:09 am    Post subject: Reply with quote

superuser.com - Recursively count all the files in a directory

"Explanation: find . -type f finds all files ( -type f ) in this ( . ) directory and
in all sub directories, the filenames are then printed to standard out one per
line"


Code:
cp -R payload_root/* "$buildroot"

num1=$(find payload_root  -not -path '*/\.*' -type f | wc -l)
num2=$(find "$buildroot"  -not -path '*/\.*' -type f | wc -l)

Echo  "Jedan: " $num1 ", Dva: " $num2
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Sat Oct 30, 2021 3:15 pm    Post subject: Reply with quote

git - Args - An easy-to-use C library for parsing command line arguments

"Long-form boolean flags with single-character shortcuts: --flag, -f.
Long-form string, integer, and floating-point options with single-character
shortcuts: --option <arg>, -o <arg>.
Condensed short-form options: -abc <arg> <arg>.
Automatic --help and --version flags.
Support for multivalued options.
Support for git-style command interfaces with arbitrarily-nested commands."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Wed Apr 05, 2023 3:32 pm    Post subject: Reply with quote

How to Use SSH Public Key Authentication

"However, using public key authentication provides many benefits when
working with multiple developers. For example, with SSH keys you can

* allow multiple developers to log in as the same system user without having to share a single password between them;
* revoke a single developer's access without revoking access by other developers; and
* make it easier for a single developer to log in to many accounts without needing to manage many different passwords."


Code:
To generate an SSH key pair, run the command ssh-keygen.

ssh-copy-id SYSUSER@x.x.x.x

ssh SYSUSER@x.x.x.x
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Thu Feb 22, 2024 8:37 pm    Post subject: Reply with quote

so - Can I put a breakpoint in shell script?

"alias combined with eval gives you basic functionality of breakpoints in
calling context"


https://www.baeldung.com/linux/debug-bash-script

Redirecting Only the Debug Output to a File...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> General Programming All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Delovski.hr
Powered by php-B.B. © 2001, 2005 php-B.B. Group