Advertisement
asanchez75

Cpanel/scripts

Feb 14th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. http://support.hostgator.com/articles/cpanel/what-do-i-put-for-the-cron-job-command
  2. http://steve-parker.org/sh/first.shtml
  3.  
  4. http://support.hostgator.com/articles/cpanel/what-do-i-put-for-the-cron-job-command
  5.  
  6. PHP
  7.  
  8. Command to run a PHP5 cron job:
  9. php /home/user_name123/public_html/cron.php
  10.  
  11. Optional flag sometimes required for a PHP cron job:
  12. php -q /home/user_name123/public_html/cron.php
  13.  
  14. Command to run a PHP4 cron job:
  15. /usr/local/php4/bin/php /home/user_name123/public_html/cron.php
  16.  
  17. All hosting types
  18. More
  19.  
  20. Command to GET a remote file:
  21. /usr/bin/GET http://www.some-domain.com/file.php
  22.  
  23. Command to run a CGI cron job:
  24. perl /home/user_name123/public_html/cgi-bin/file.pl
  25. SSH Extras
  26.  
  27. Command to run a shell script cron job:
  28. /bin/sh /home/user_name123/public_html/file.sh
  29.  
  30. Command to import a database:
  31. mysql -u mysql_user -ppassword database_name < backup.sql
  32.  
  33. Command to export a database:
  34. mysqldump -u mysql_user -ppassword database_name > backup.sql
  35.  
  36. ============================================================================
  37.  
  38. http://steve-parker.org/sh/first.shtml
  39.  
  40. ============================================================================
  41.  
  42. For our first shell script, we'll just write a script which says "Hello World". We will then try to get more out of a Hello World program than any other tutorial you've ever read :-)
  43. Create a file (first.sh) as follows: first.sh
  44.  
  45. #!/bin/sh
  46. # This is a comment!
  47. echo Hello World # This is a comment, too!
  48.  
  49. The first line tells Unix that the file is to be executed by /bin/sh. This is the standard location of the Bourne shell on just about every Unix system. If you're using GNU/Linux, /bin/sh is normally a symbolic link to bash.
  50.  
  51. The second line begins with a special symbol: #. This marks the line as a comment, and it is ignored completely by the shell.
  52. The only exception is when the very first line of the file starts with #! - as ours does. This is a special directive which Unix treats specially. It means that even if you are using csh, ksh, or anything else as your interactive shell, that what follows should be interpreted by the Bourne shell.
  53. Similarly, a Perl script may start with the line #!/usr/bin/perl to tell your interactive shell that the program which follows should be executed by perl. For Bourne shell programming, we shall stick to #!/bin/sh.
  54.  
  55. The third line runs a command: echo, with two parameters, or arguments - the first is "Hello"; the second is "World".
  56. Note that echo will automatically put a single space between its parameters.
  57. The # symbol still marks a comment; the # and anything following it is ignored by the shell.
  58.  
  59. now run chmod 755 first.sh to make the text file executable, and run ./first.sh.
  60. Your screen should then look like this:
  61.  
  62. $ chmod 755 first.sh
  63. $ ./first.sh
  64. Hello World
  65. $
  66.  
  67. You will probably have expected that! You could even just run:
  68.  
  69. $ echo Hello World
  70. Hello World
  71. $
  72.  
  73. Now let's make a few changes.
  74. First, note that echo puts ONE space between its parameters. Put a few spaces between "Hello" and "World". What do you expect the output to be? What about putting a TAB character between them?
  75. As always with shell programming, try it and see.
  76. The output is exactly the same! We are calling the echo program with two arguments; it doesn't care any more than cp does about the gaps in between them. Now modify the code again:
  77.  
  78. #!/bin/sh
  79. # This is a comment!
  80. echo "Hello World" # This is a comment, too!
  81.  
  82. This time it works. You probably expected that, too, if you have experience of other programming languages. But the key to understanding what is going on with more complex command and shell script, is to understand and be able to explain: WHY?
  83. echo has now been called with just ONE argument - the string "Hello World". It prints this out exactly.
  84. The point to understand here is that the shell parses the arguments BEFORE passing them on to the program being called. In this case, it strips the quotes but passes the string as one argument.
  85. As a final example, type in the following script. Try to predict the outcome before you run it:
  86. first2.sh
  87.  
  88. #!/bin/sh
  89. # This is a comment!
  90. echo "Hello World" # This is a comment, too!
  91. echo "Hello World"
  92. echo "Hello * World"
  93. echo Hello * World
  94. echo Hello World
  95. echo "Hello" World
  96. echo Hello " " World
  97. echo "Hello \"*\" World"
  98. echo `hello` world
  99. echo 'hello' world
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement