I would like to do something if the output of a shell script contains the string "Caddy 2 serving static files on :2015". This is what I have so far but the beach ball is just spinning. It seems it is because of the last command in my bash script which starts a server. There is no exit in the bash script so it does not end. The output of the bash script is correct and I can see "Caddy 2 serving static files on :2015". But it seems this code is only working with a bash script which has a end.
- (IBAction)localHost:(id)sender
{
// execute bash script to start server
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/bin/bash"];
[task setArguments:[NSArray arrayWithObjects:[[NSBundle mainBundle] pathForResource:@"caddy-start" ofType:@""], nil]];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
NSFileHandle *file = [pipe fileHandleForReading];
[task launch];
NSData *data = [file readDataToEndOfFile];
NSString *result = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSLog(result);
NSString *string = result;
NSString *substring = @"Caddy 2 serving static files on :2015";
if ([string rangeOfString:substring].location != NSNotFound) {
NSLog(@"Yes it does contain that substring");
}
else if ([string rangeOfString:substring].location == NSNotFound) {
NSLog(@"No it does NOT contain that substring");
}
// wait 3 seconds
[NSThread sleepForTimeInterval:3.0f];
// open local host
//[self loadPage:@"http://127.0.0.1:8000/"]; // python2 server
[self loadPage:@"http://127.0.0.1:2015/"]; // caddy server
//[self loadPage:@"http://localhost:2015"];
}
And here is my bash script:
#!/bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd "${DIR}"
pwd
#open http://localhost:2015
# kill server if already running
kill -9 $(lsof -ti:2015)
(./caddy_darwin_amd64 stop) &
(./caddy_darwin_amd64 file-server --listen :2015 --root Content/) &
Post
Replies
Boosts
Views
Activity
Greetings, everyone!
In case it proves helpful, I've crafted a Bash script to streamline the notarization process.
Here's a breakdown of its features:
Prompts you to select the app for notarization
Offers optional codesigning before notarization
Generates a ZIP file for notarization
Requests your credentials (Apple ID, Team ID, and app-specific password)
Submits the ZIP file for notarization
Cleans up by deleting the ZIP file used for notarization
Staples the app after notarization
Creates a new ZIP file for distribution
You can check it out on GitHub: Notarization Assistant
Hello fellow developers,
I've come across a bit of a challenge and would appreciate some insights. I successfully backed up my Developer ID Application certificate as a .p12 file and smoothly imported it into my login keychain. However, when attempting to import it into my iCloud keychain for an added layer of backup security, I encountered two error messages:
"One object could not be imported."
"The selected keychain could not be found."
Any thoughts or suggestions on resolving this hiccup would be greatly appreciated!
Thanks in advance for your expertise!