Hot answers tagged

16

Running sudo su user01 in a script does not mean the following commands are sent to the resultant shell. In fact, it likely means a new shell is spawned as user01, which never exits! Two things: You can execute a command as another user either by passing the -c 'command...' argument to su, like su user01 -c '/etc/init.d/script start'. Starting a service ...


16

You probably have a carriage return (^M) at the end of your #! line. The format of the #! line is very strict, and carriage return is not allowed there, unless your interpreter is actually called /bin/bash^M There will never be carriage returns in a file created with a proper unix editor, unless you go out of your way to add them. When editing an existing ...


9

You need IF EXIST instead of just IF for batch programming. e.g. IF NOT EXIST "C:\Program Files\Microsoft Security Client" ( :: Install product )


6

Put the command in /etc/rc.local.


6

You might want to look at achieving this via two separate methods, i.e. one to set FF as default, the other to launch it at login. That said, in case you want to know, default browser setting is stored in the registry under HKEY_CURRENT_USER\Software\Classes\http\shell\open\command Use your preferred method for setting registry entries (with your ...


6

In PowerShell: Import-Module ActiveDirectory Get-ADUser MDMarra -Properties scriptpath | Select scriptpath In cmd: dsquery user -samID MDMarra | dsget user -loscr This will return the path of the logon script set in the Profile tab of ADUC. or Just install ADUC on your workstation and look at the Profile tab for the user in question. You don't need ...


6

Your understanding is correct. When your company gets to the size that you need to bring in a dedicated Windows sysadmin they're going to be unhappy that you did this. I can't imagine that your logic is so complex that it couldn't be solved by the built-in functionality in Group Policy. Security Group filtering, WMI filtering (which is performance-...


5

You can use my init script. It's based on /etc/init.d/skeleton and seems to work well: #! /bin/sh ### BEGIN INIT INFO # Provides: Xvfb # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start Xvfb. # Description: Start the X virtual ...


5

You could put something in /etc/crontab and run it @reboot @reboot username /etc/init.d/script start


5

Group Policy Filtering: You're doing it wrong (or at the very least you're doing it the hard way). Create a Security group for the computers that you DO want the policy to apply to. Add the appropriate computer accounts to the group. On the Scope tab of the GPO, in the Security Filtering section, remove all entities and add the Security group you created ...


4

On the CentOS machine, create a file in your home directory named .bashrc and set your environmental variables in there. For example, the contents of the file can be: export VARIABLE=foo Here's some discussion of this: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_01.html [edit] Thanks for the clarification. You can use the SendEnv and ...


4

I suppose the shell TERMs it when it exits, which would be immediately, due to the '&'. Maybe you want to use start-stop-daemon? E.g: start-stop-daemon --start -b -x /usr/bin/Xvfb :1 I suppose if you want the help of the startx wrapper, you may want to run your shellscript instead.


4

Since you're running AD, why don't you try distributing these products via MSI and GPO?


4

Sorry for not answering (my own question) sooner. So, this is how I finally settled my problem. On Startup, the Startup Script creates an at job. Since Startup Scripts run as SYSTEM, the at job will similarly run under SYSTEM privileges. The at job is configured to run 2 minutes after creation. The command in the at job is the actual workload script. ...


4

If your service already has an init script, you can add it to the default runlevel by running: # rc-update add apache2 default If not, depends on which services system you're using, add your scripts to the /etc/conf.d/local.start or /etc/local.d/baselayout1.start, something like this: cd /path/to/your/app && thin start


4

I do what you're looking at doing all the time. When you say "I then set permissions on the GPO to deny access to that group" it's not clear what you're doing. Here's my workflow for denying a group the rights to apply a GPO: Create Global Security Group "Computers exempt from printer deletion" Open Group Policy Management, locate the GPO to delete ...


4

As drive letters are ephemeral, it would be best to use UNC paths instead of drive letters. If the service is unable to handle UNC paths, consider creating a symlink to the destination like mklink c:\remotenetdir \\server\remote\netdir and use the local path (c:\remotenetdir) in the service configuration. Obviously, the service account would need to have ...


3

There is already a start-up script for running local commands in /etc/rc.d/local. You can add a line there which executes your program. If your script requires startup/shutdown/restart capabilities, you can add your own script to /etc/init.d. Start by looking at the existing scripts to figure out how to specify dependencies. Once you've created your script, ...


3

You need to transition this to a logon script, or use the built in application deployment options. The problem you are running into is that during the start up script phase the effective user is not the logged in user - since these scripts are run even before the user logon prompt is presented - but it is running as the SYSTEM user. Personally I would ...


3

Assuming startup script is a batch file: The CALL statement was introduced in MS-DOS 3.3 It is used to call other batch files within a batch file, without aborting the execution of the calling batch file, and using the same environment for both batch files. http://www.robvanderwoude.com/call.php


3

You should grab a copy of psexec and run psexec -s path\to\script.bat. That will run it as System. That's a more accurate manual test than running it as the logged in user, since startup scripts run as SYSTEM.


3

Since, you're running Ubuntu, you can wrap memcache tasks into an Upstart configuration. The "hook" to invoke a script after memcached starts would be in the post-start section of the Upstart configuration. Your config will then look something like: # memcached - in-memory cache # description "memcached" start on (local-filesystems and started networking)...


3

Modify /etc/init.d/boot.local to add what you want.


3

rc startup order is determined by rcorder, as you've already determined. This process for determining startup order is automatic, and the man page for rcorder is relatively self-explanatory, but you may will want to spend some time reviewing Practical rc.d scripting, and the rc man page before making any changes. In your particular case, you can tell ...


3

The services on a CentOS operating system are managed using chkconfig. Use chkconfig --list to review the currently managed services. You can mark a service to automatically start at a defined runlevel by issuing: # chkconfig someservice on Read the chkconfig(8) manpage for the details.


3

How can I get the script to run even if I didn't previously logoff? A Logon script, by definition, runs at Logon. If you don't log off then the script isn't going to run again. It doesn't run on a disconnect/reconnect to an already logged on session.


3

Two alternatives to have systemd create directories, typically the easiest is to declare a RuntimeDirectory in the unit file of your service: RuntimeDirectory=, RuntimeDirectoryMode= Takes a list of directory names. If set, one or more directories by the specified names will be created below /run (for system services) or below $XDG_RUNTIME_DIR (for ...


3

You can add your script in ~/.bash_profile where ~ represents the homedir of the user for which running the script is intended.


2

Hmmm... What you're doing should work. That's not much consolation, I know, but I use a LOT of startup scripts (thousands of invocations on client comptuers throughout my Customer sites every day) and I don't have problems with script execution reliability. I'd add an "On Error Goto 0" after the registry read so that any other errors in the script execution ...



Only top voted, non community-wiki answers of a minimum length are eligible