A simple "sudo" script
Hi, I wrote a simple "sudo" script for people who prefer to use su rather than sudo.
#!/bin/bash
while [ -n "$1" ]
do
command="${command} $1"
shift
done
su -c "$command"
Usage:
put it in /usr/sbin, then for example, do
sudo pacman -Sy
Password:
enter root password
Advantages:
for those who don't like sudo, this sudo script is convenient for one line commands
simple bash completion
Hope you find it useful
Xilon wrote:Couldn't you just do:
alias sudo='su -c'
That would require you to manually put ' ' around your command, and miss bash completion.
mucknert wrote:Uh. sudo allows a much finer selection of rights. You can say what user or group is allowed to execute with its own password (or no password at all) instead of the root pw. That's a lot more than your script does and those are good reasons, too. Read up on sudo one day. You will be suprised.
Thanks for your suggestion, I just had a quick read through sudo and sudoers. This is some stuff I found:
The time stamp issue was never a big one, and you can configure the time or disable it. I find sudo -k useful too.
I thought sudo might add security risk if the user password was compromised, but you can configure sudo to ask for the root password. However, this would defeat the purpose for those who disable root.
I also have a questions: if you want to do access control, why would you prefer sudo over simple file permissions? Or is sudo primarily used as a finer access control scheme?
Again, thanks for your advice, I really appreciate it. Please point out anything wrong with my questions. The manual was pretty long, so I'm bound to miss something.
Similar Messages
-
Simple button script not working
I am using AS2 and need help figuring out why this simple button script is not working:
stop();
buttonWS1.onRelease = function(){
gotoAndStop("Stage1and2_Boss",4);
buttonWS2.onRelease = function(){
nextFrame();
//end
My buttons are the square letter-puzzles below. They are images that I converted to "symbols" (specifically, buttons). I put their names as above (buttonWS1, buttonWS2, etc.) in the "instance names" boxes.
I have no idea what is going on. Please help!Hi -
1. Yes, buttonWS2 is the instance name
2. The only code attached to it is the code I pasted above.
3. onRelease does not execute because my trace statement does not appear in the output
Here is the modified code for buttonWS2:
buttonWS2.onRelease = function(){
trace("clicked!");
nextFrame();
Question: It shouldn't matter if I have commented-out code within that set of codes should it?:
buttonWS2.onRelease = function(){
//if (puzzleschosenarray[0] == 2 || puzzleschosenarray[1] == 2) {
// cannot be chosen -- make button non-functional
//else{
//puzzleschosenarray[roundnumber-1] = 2;
trace("clicked!");
nextFrame(); -
Tidy -- simple python script to clean annoying files and directories
Hi all,
recently I opened a much-used flash drive and there was a lot of files like Thumbs.db, Mac OS' ._*, .DS_Store, etc all over it, making using it really annoying.
So I decided to mimic a simple utility I saw as a plugin in Rockbox, which takes all of these files and deletes them.
The result is a simple python script which you can find at:
http://github.com/houbysoft/short/blob/master/tidy
Usage should be self-explanatory. Be warned, by default, it deletes everything that matches the regular expressions without warning (this should be fine though, so if you want to be safe, try the -s and -v (simulate, verbose) or -p (prompt) options first.
As usual, any feedback is welcome, and if you know of other files it should clean, please post them here!Hi all,
recently I opened a much-used flash drive and there was a lot of files like Thumbs.db, Mac OS' ._*, .DS_Store, etc all over it, making using it really annoying.
So I decided to mimic a simple utility I saw as a plugin in Rockbox, which takes all of these files and deletes them.
The result is a simple python script which you can find at:
http://github.com/houbysoft/short/blob/master/tidy
Usage should be self-explanatory. Be warned, by default, it deletes everything that matches the regular expressions without warning (this should be fine though, so if you want to be safe, try the -s and -v (simulate, verbose) or -p (prompt) options first.
As usual, any feedback is welcome, and if you know of other files it should clean, please post them here! -
SIMPLE login script install of zfd4 agent?
Is there is simpler way of installing the zfd4 agent via a login script when
I'm not using an intermediate tier or use the application explorer. The
login script examples I've found onlnie (and information in the Novell docs
and Novel Press books) seem complex and frought with pitfalls...
Thanks,
KB> I'm reviewing this TID; I may be able to do this on my own. However, if
> anyone has an example, working "simple" login script they could post as
an
> example, it would be REALLY appreciated....
>
> Thanks!
> KB
> "KB" <[email protected]> wrote in message
> news:mHgfg.738$[email protected]..
> > Forgot to mention - I want to run this in silent mode, and need to
handle
> > the issue where someone already has the agent installed...
> >
> > Thanks,
> > KB
> >
> > "KB" <[email protected]> wrote in message
> > news:Dfgfg.703$[email protected]..
> >> Is there is simpler way of installing the zfd4 agent via a login
script
> >> when I'm not using an intermediate tier or use the application
explorer.
> >> The login script examples I've found onlnie (and information in the
> >> Novell docs and Novel Press books) seem complex and frought with
> >> pitfalls...
> >>
> >> Thanks,
> >> KB
> >>
> >
> >
>
>
Hi,
your Login Script must be seen like this:
#z:exist c:\programme\novell\zenworks\nalwin32.exe
if "%ERRORLEVEL"="0" THEN GOTO NOTHING
#z:\zfdagent\agent.bat
NOTHING:
END
the agent.bat is a batch File to install the agent in silent mode
it looks like that:
msiexec /i z:\zfdagent\zfdagent.msi /qn ADDLOCAL=ALL EDITABLE_MT_ADDRESS=1
STARTUP_APPWINDOW=1 STARTUP_APPEXPLORER=0 REBOOT=ReallySuppress /l*v %
WINDIR%\zfdagent.log
the z:\zfdagent is a subdirectory in the sys:\system\Public where
zfdagent.msi file exists.
hier is a link to download exist.exe
Download: http://www.novell.com/coolsolutions/...oads/exist.zip
Best regards
Issam -
Simple Resizing Script - Hopefully better eyes will prevail
I'm working on a simple resizing script to incrementally resize an image in 5% steps up to the set limits as defined by the variables; newImageHeight & newImageWidth. I'm currently running this script in Photoshop CS4 on an Intel Mac.
The script works fine for horizontal format images but vertical images scale incrementally in significantly larger steps than 5% and the final output is well above the limit set by the variable "newImageHeight".
I'm sure it's something simple that I've just overlooked. Any help would be most appreciated.
TIA
#target photoshop
// Sets Adobe Photoshop to use pixels and display no dialogs.
app.preferences.rulerUnits = Units.PIXELS;
var doc = app.activeDocument;
var imageFormat;
var newImageHeight = 4000; // Sets the new image height to 4000 pixels.
var newImageWidth = 2880; // Sets the new image width to 2880 pixels.
if (doc.height.value > doc.width.value){ // Determines whether the image is vertical or horizontal in format.
imageFormat = 1;
}else{
imageFormat = 2;
if (imageFormat == 1) {
alert("Re-Scale Portrait Format");
while (doc.height.value < (newImageHeight * 0.923550372529964)){
alert(doc.height.value);
doc.resizeImage (doc.height * 1.05), ResampleMethod.BICUBIC;
alert(doc.height.value);
doc.resizeImage (doc.height * (1 / (doc.height / newImageHeight))), ResampleMethod.BICUBIC;
}else{
alert("Re-Scale Landscape Format");
while (doc.width.value < (newImageWidth * 0.923550372529964)){
alert(doc.width.value);
doc.resizeImage (doc.width * 1.05), ResampleMethod.BICUBIC;
alert(doc.width.value);
doc.resizeImage (doc.width * (1 / (doc.width.value / newImageWidth))), ResampleMethod.BICUBIC;
// EOFCheck resizeImage out the Object Model Viewer in ESTK.
Document.resizeImage (width: UnitValue , height: UnitValue , resolution: number , resampleMethod: ResampleMethod )
So I think the line
doc.resizeImage (doc.height * 1.05), ResampleMethod.BICUBIC;
should rather be
doc.resizeImage (doc.width * 1.05, undefined, undefined, ResampleMethod.BICUBIC);
or
doc.resizeImage (undefined, doc.height * 1.05, undefined, ResampleMethod.BICUBIC);
What is the Script supposed to achieve anyway?
It’s not based on the obsolete concept of incremental resizing for better results, is it? -
Help with simple Automator script
I have a simple Automator script for updating a specified folder with files from another folder. It consists of only two actions:
1. Get Folder Contents (from the folder I drop on the Automator executable).
2. Copy Finder Items.
I left the option "replace existing files" unchecked because there's no point in replacing a bunch of files that already exist (we're talking about 4000-5000 files in the source folder). I assumed that meant to ignore any existing files but, on the contrary, I found out that the script is copying duplicates of all the existing files -- making my target folder about 9000 files strong!
How do I get a command into the middle of this script to restrict the Copy Finder Items command to files that do not already exist in the target folder? (It would be even nicer if it could check for files that are older than the files being copied and actually replace (only) those as well.)
Any ideas?If you need the Terminal window to stay open, then you're looking at scripting Terminal. You can do this with Automator's run applescript action, or you can just use Script Editor (in Applications > AppleScript). Either way you will need to save the workflow/script as an application and drag it to your Login Items (in System Preferences > Accounts).
click here to open this script in your editor<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">tell application "Terminal"
activate
set commands to "cd /Users/lenny/ventrilo/
/Users/lenny/ventrilo/ventrilo_srv"
do script commands in front window
end tell</pre>
PowerMac G5 (June 2004) 2x1.8GHz 1.25GB, PowerBook G4 (12-inch DVI) 1x1GHz 768MB Mac OS X (10.4.3) -
Simple bash scripting help needed..
I want to learn som simple bash scripting in order to automate various tasks.. Im totally noob, so bear with me
First of all I would like to set configs without using nano.. is there a simple command for this? For example if i want change my hostname in /etc/rc.conf.. how can i print the current vallue and how can i change it`?
i was thinking something like this to get the current value:
# cat /etc/rc.conf | grep HOSTNAME=
which returns HOSTNAME="myhostname"
how can i change this value with one or more commands whitout touching the rest of the file?abesto wrote:
A slightly naive solution:
CHOICE="lisa"
NAMES="homer marge lisa bart maggie"
if [ "`echo \" $NAMES \" | grep \" $CHOICE \"`" ]; then
echo "this is how you do it"
fi
The extra spaces inside the escaped quotes are to ensure that only a whole word is "matched".
You can also replace the elif's with a loop through a list of "the other variables". Then you'd use the loop variable instead of $CHOICE above.
grep can check on word-bounderies with \< and \>, or with the -w switch. The -q switch suppresses any messages and exits with exit-code 0 when the first match is found:
if echo "${NAMES}" | grep -qw "${CHOICE}"; then
Nice and readable, should work, but i haven't tested it
EDIT:
Procyon wrote:CHOICE="lisa"
NAMES="homer marge lisa bart maggie"
if [[ $NAMES =~ $CHOICE ]]; then echo match; fi
This one also matches elisa, ie. no check on word bounderies. You should be carefull with that
Last edited by klixon (2009-04-23 09:40:22) -
Solaris 11 - run a simple BASH script on computer startup
I need to have a simple BASH script run on my Solaris 11 machine automatically whenever the computer (re)starts. It should be run with root permissions and after the computer has fully booted. What is the easiest way to do that?
Thank you
DusanHi user9368043
Yes, that should be right, and be intended this way.
See /etc/rc3.d/README and the following part from smf(5):
Legacy Startup Scripts
Startup programs in the /etc/rc?.d directories are executed
as part of the corresponding run-level milestone:
/etc/rcS.d milestone/single-user:default
/etc/rc2.d milestone/multi-user:default
/etc/rc3.d milestone/multi-user-server:default
Your question concerning upgrading to Solaris 11.1:
In the Gnome menus, you should look for (and start)
System --> Administration --> Update Manager
Let it do its work. It will give you a new boot environment, containing Solaris 11.1. Possibly, you have to perform upgrading twice. With "beadm activate", see beadm(1M), you can go back to Solaris 11.0 whenever you want.
"Local" parts of your zfs root pool, like /usr/local, home directories, /root, and so on, should be in separated file systems, and be mounted outside the root pool before upgrading. They are availlable then from any boot environment, and will not be duplicated. See more in zfs(1M), zpool(1M).
I strongly recommend upgrading. Solaris 11.1 is great. -
Hi,
I need a simple TCL script, that picks up the phone, plays a greeting message and then does DID further in without caller intervention. Currently I have 2811 with a BRI, the local telco sends only the last two digits that are a direct match to the extensions of the IP phones and I do DID.
I analyzed b-acd-aa script, that is shipped with the CME, but in fact I do not need such a complex state machine with digit collection, hunt groups, etc.
(http://www.cisco.com/en/US/docs/voice_ip_comm/cucme/bacd/configuration/guide/cme40tcl.html)
I believe I need something like:
application
service foo flash:foo.tcl
param welcome-prompt foo.au
dial-peer voice 10 pots
service foo
port 0/2/0
incoming called [0-1].
direct-inward-dial
Please advise wether to build a new TCL script, or to try to provide all the necessary parameters to the existing scripts and try to make them work for what I need (e.g. drop-through, etc.)
Any comments are welcome!
Zzzz.You can use b-acd/aa in drop-through mode.
if you are interested in acquirinf a num2name script that does it and much more, you can contact me at the address present in my profile. -
Omodoro - simple python script to use the pomodoro technique
Hello everyone,
did you ever have the feeling that your productivity is not high enough?
That you're wasting too much time on reddit, facebook, youtube or <insert-online-community-here>?
Maybe you should try the pomodoro technique! It keeps you focused on important tasks, lets you set goals to achieve and also makes sure that you take breaks to regain energy.
I wrote a simple python script to work with the pomodoro technique. It's called omodoro. It displays reminders and ensures that you do your tasks but also take your breaks.
Maybe anyone of you wants to try it out and provide feedback - it would be appreciated!
It's available on github: omodoro
There's also a PKGBUILD in the AUR:
https://aur.archlinux.org/packages/omodoro-git/
I hope, you like it!
Greetings,
Oliver
Last edited by okraits (2014-02-11 22:17:54)I've always wanted to try the pomodoro technique out but never actually have. I guess this is my excuse to do it. Looks like a nice little script; I'll check it out when I get the chance.
-
Simple UCCX script for IVR,Welcome message then press 1 and press 2
Dear Experts;
I have uccx 10.5.
I want to write a simple IVR script as below.
Step-1- Welcome message.with press 1 for Sales and Press 2 for Marketing
step-2 User Press 1 then transfer the call to Sales Skill Group.
Step-3 User press 2 then transfer the call to Marketing Skill group.
My doubt is how to accept when user press 1 and match the value and then transfer the call to that skill group.
Really appreciate any link or script for this.
Regards
DebashisDear Martyn;
Thanks a lot that was very nice and valuable information.
just want to ask which palette i have to use to save the value 1 or 2 when user press 1 or 2.
I know using Menu we can create different Menu option.
After user press 1 it will go SALES skill group and if press 2 Go MARKETING Skill group.
Appreciate if you can help me in this regard.
Regards
Debashis -
Simple BASH script to update subversion files
This is just a simple BASH script that will update all .svn files in a specified directory. If an update fails, it will attempt to update all the subdirectories in the failed one, so as much will be updated as possible. Theoretically, you should be able to supply this script with only your root directory ( / ), and all the .svn files on your computer will be updated.
#! /bin/bash
# Contributor: Dylon Edwards <[email protected]>
# ================================
# svnup: Updates subversion files.
# ================================
# If the user supplies no arguments
#+ then, update the current directory
#+ else, update each of those specified
[[ $# == 0 ]] \
&& dirs=($PWD) \
|| dirs=($@)
# Update the target directories
for target in ${dirs[@]}; do
# If the target file contains a .svn file
if [[ -d $target/.svn ]]; then
# Update the target
svn up $target || {
# If the update fails, update each of its subdirectories
for subdir in $( ls $target ); do
[[ -d $target/$subdir ]] &&
( svnup $target/$subdir )
done
# If the target file doesn't contain a .svn file
else
# Update each of its subdirectories
for subdir in $( ls $target ); do
[[ -d $target/$subdir ]] &&
( svnup $target/$subdir )
done;
fi
doneCerebral wrote:
To filter out blank lines, you could just modify the awk command:
${exec awk '!/^$/ { print "-", $_ }' stuffigottado.txt}
very nice; awk and grep: two commands that never cease to amaze me. -
Create a simple shell script thing?
Hey,
I'm trying to make a simple command script thing. I have no idea what I'm doing though.
I just want a file that I can click and open in terminal that will:
1. ssh [email protected]
2. auto enter the password (if this is really complicated then it can be skipped)
3. cd public_html/blog
4. svn up
5. like 5 sec delayed exit (if possible)
I'm thinking this is a really easy thing to do for someone who knows what they're doing.
So can someone tell me what I have to do to make this? I would really like to learn how to do this.
Thank you
Last edited by FLCLFan (2008-10-12 20:06:20)Instead of making a script, you could just as well write a bash function for this and put it in your .bashrc.
something like this:
update-svn-on-domain ()
ssh -t [email protected] 'svn up public_html/blog'
when the svn up is done, the ssh command stops, and the function returns. it does everything you want except auto entering passwords.
i strongly discourage auto entering passwords. i recommend you to setup rsa key authentication -
Not being a regular user of terminal on OSX, I have managed to forget how to run a simple shell script. The purpose of the script is to rename a set of files contained in a specific directory. Here is a sample of the script I wrote some time back:
mv product_22.jpg 080688614423.jpg
This command repeats for each file I need to rename. My recollection is that I simply put the actual script text file in the same directory as the images to be renamed and drag the script file into a new terminal window and hit enter to run. When I try this however I receive the following error:
ord2: Permission denied
Can anyone help me out here? I'm running 10.2.8. I seem to beforgetting a critical step somewhere along the way.
Thanks
Mac OS X (10.2.x)Have you set the execution bit for the script? When not, use: chmod 755 script.
-
Creating simple shell script packages to deploy with ARD and TaskServer
I am looking for a simple step by step on how to create a package that can be deployed using ARD, to run a simple shell script like
"softwareupdate -i -a"
A brief search here returned nothing, but perhaps I was not using the correct terms.
Ultimately, I want to use ARD to run software update on ~400 Macs.
Thanks in advance for your help.
BillIf I send it as a unix command, it will run only on machines that are currently awake and responding to ARD.
If I can set it up as a package, then I can use Task Server to "deploy" the command to machines that are not currently online. When the machines next contact the Task Server, they will be told to run softwareupdate.
Maybe you are looking for
-
Problem in merging two files using BPM
Hello Frens, I am doing a scenario for merging of two files N:1 using BPMu2026 I have to merge two files into one file. The two input files are as below : File1 : Id, Name, Age, Place File2 : ID, Street, Adrress And output File is : ID, Name, Age,pla
-
Bonjour , j ai un probleme avec mon port mini display , j ai brancher mon adaptateur mini display port pour hdmi sur mon mac et raccordé ma tv philips 119 cm recente avec un cable hdmi 1.4 qui fonctionne sur mon autre pc, et rien ne se passe. Dans le
-
My wifi button is frezon and I tried turning my phone off for a period of time and reset my phone but the button is still frezon it want slide over to turn on my wifi. Is there any other way to fix without going to apple to get it fixed?
-
Issues with vietnamese language
Hi , I need help in locating the right font , NLS_LANG , database charactersets for a Vietnamese based forms application. I am having issues with VIETNAMESE_VIETNAM.VN8MSWIN1258 because some of the words are not coming properly in the forms . For exa
-
Glossary interaction xml import not working
If I use the glossary interaction xml import, the resulting window is mis-sized (scrunched up to the top) even if I use Adobe's sample xml file (glossary.xml). Has anyone been able to get this to work correctly? Even if I add manually, it still cuts